USART AND PIC 18F2550

General discussion on mikroC.
Post Reply
Author
Message
jaycec
Posts: 7
Joined: 11 Jul 2010 13:12

USART AND PIC 18F2550

#1 Post by jaycec » 09 Jan 2011 20:43

Hi
i wrote a program for usart reception on pic18f2550,but it is not working at all I cannot find what the problem is,here is my code please find out what the problem is.

mikroc Version: 6.2.1.0
clock 8mhz
pic18f2550
===================================================================================
//my code
void main()
{
char recdata;
usart_init(1200);
adcon1=0x0f;//to configuare porta as digital io port
cmcon=0x07;//to configuare porta as digital io port
trisa=0x00; //porta output
porta.f0=1;
while(1)
{

recdata=usart_read();
if(recdata=='A')
porta.f0=0;
else
porta.f1=1;
}
}

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: USART AND PIC 18F2550

#2 Post by Dany » 12 Jan 2011 16:21

Hi, in mikroPascal there is a function "Uartx_Data_Ready" which can be called before (meaningfull) uart data (=1 byte) is read. I do not know if this function also exists for mikroC? I assume it should be used here also.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroC General”