Pic 16F877 and Virtual Terminal in Proteus communication

Status
Not open for further replies.

Asteroid

Newbie level 4
Joined
Jan 16, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,314
PIC and Usart

Hi to all friends.

I am new to the world of programming microcontrollers and trying to set up communication between my Pic 16F877 and Virtual Terminal in Proteus.

I have written the following code. But it is not working. Please tell me what's wrong with it.


//Pic 16F877
// Clock 20 Mhz

unsigned char txt[8];

unsigned int i;

void main() {


Usart_Init(9600);
Lcd_Init(&PORTD);

txt[0]="12";
txt[1]="20";
txt[2]="50";
txt[3]="10";
txt[4]="40";
txt[5]="80";
txt[6]="76";
txt[7]="48";

for (i=0;i<8;i++)

Usart_Write(txt);


}
 

Re: PIC and Usart

Not at all familiar with the pic you're using so not sure how the uart is going to like it when your *for* loop pounds the uart buffer every pass through at processor rates before it has a chance to empty each byte out. Then again maybe the called function is smart enough to handle it.

Might try a while loop under your call "Usart_Write(txt); " based on a UART BUSY or DONE flag if one is available.
 

PIC and Usart

u r a beginner, so dont use Usart_init() function...trty to do it by setting registers..
 

instead of writing usart write uart1
and make sure that you ticked the icon of ( uatr ) in the library
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…