Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem using PIC16F877 Microcontroller

Status
Not open for further replies.

imranshoaib

Junior Member level 2
Joined
Nov 23, 2007
Messages
20
Helped
3
Reputation
4
Reaction score
1
Trophy points
1,283
Activity points
1,428
Hi all,

The following code is suppose to do the following but it is giving an error, please help.

At start up, a string "Please Enter S-T" should show on top line of the LCD. Press and hold push button RB6 to increment the sampling time from 1 to 10 seconds shown on line 2 of the LCD. Release the pushbutton once the required sampling interval has been set. The display should roll back to 1 when it exceeds 10 seconds.

#include"io16f877.h"
#include"LCDdrive.h"

unsigned int x = 0; //declare variable "x"

void main(void)
{
LCD_initialise(); //function to initialise the lcd display
LCD_cursor(0,0); //function to move the cursor position
LCD_puts("Please Enter S-T"); //function to display a string on lcd

TRISB = 1; //define port b as inputs
while(1)
{
if(RB6==1)
{
del(3);
x++; //counter to hold the sampling time value
if(x>10)
x = 1;
}
LCD_cursor(0,1); //function to move the cursor position
LCD_display_value(x); //function to display the x value on lcd
}
}

Regards,

Imran
 

I think your problem is TRISB = 1 ...... this statement configures only RB0 as input while all others are configured as output
If you want to configure whole portB as input you should use TRISB = 0xFF; or TRISB = 255;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top