Problem with mikroC USART PIC code

Status
Not open for further replies.

pietro10

Junior Member level 1
Joined
Mar 15, 2010
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,405
hello
PIC16F88 beams max 232 mikroC windows XP hyperterminal
the code below to make a serial peak with Hyperterminal
LED blink red if I pressed the letter 'a' keyboard
and to extinguish the letter 'z'
but typed letters 'a' or 'z' on the keyboard has no effect


/ * PB0 PB7 out in order the two transistor 2N222A * /
/ * PA0, PA1, PA7, PA6 out in order both ULN2803A * /
/ * PA4 PB4 enter into left stop right * /
/ * PA2 out in order to control the transistor bridge voltage divider * /
/ * PA3 come in to verify the intention bridge voltage divider * /
/ * PB2 in PB5 enter to USART * /
/ * The letter a = 01100001 = 01111010 the letter z * /


void main (void)

{
int gauche=0;
char codeRecu;

char code1=0b01100001;
char code2=0b01111010;
OPTION_REG = 0b00000111;
OSCCON = 0b01100010;
ANSEL = 0;
CMCON = 0x07;
TRISA = 0b00010000;
TRISB = 0b00110100;
Usart_Init (9600);
Delay_ms(100);
while (1)

{


PORTB = 0b00000000 ;
PORTA = 0b00000000 ;



if (USART_Data_Ready())
{
codeRecu=USART_Read();
}



if (codeRecu==code1)
{
gauche=1;
}

else if (codeRecu==code2)
{
gauche=0;
}
if(gauche)/*diodes allumé*/
{
PORTB = 0b10000001 ;// bit7 AND bit0 5VDC
PORTA = 0b01000001 ;// Bit6 AND bit0 5VDC
delay_ms (1000) ;// Tempo
PORTA = 0b10000010 ;// bit7 AND Bit1 5VDC
delay_ms (100) ;// Tempo
}
}
}
Code:
 

Re: usart pic

Hi
See this project , I think can help you about registers of UART
 
Re: usart pic

I look at the file and the example mikroC for Software UART Library
So voila a new code
but that still does not

Code:
void main (void)

{
int gauche=0;
char rec=0;
char codeRecu=0;
char code1=0b01100001;/*The letter a turns the LED */
char code2=0b01111010;/*The letter z to stop the LED*/
OPTION_REG=0b00000111;
OSCCON    =0b01110010;/*8Mhz INTRC_IO*/
CMCON = 7;
ANSEL = 0;/*digital*/
TRISA = 0b00010000;
TRISB = 0b00110100;
rec=Soft_Uart_Init(PORTB, 2, 5, 9600, 0);
Delay_ms(100);
while (1)

{
PORTB = 0b00000000 ;
PORTA = 0b00000000 ;
codeRecu=Soft_Uart_Read(&rec);
if (codeRecu==code1)
    {
    gauche=1;
    }

 else if (codeRecu==code2)
    {
    gauche=0;
    }


if(gauche)/*diodes allumé*/
{
PORTB = 0b10000001 ;// bit7 AND bit0 5VDC
PORTA = 0b01000001 ;// Bit6 AND bit0 5VDC
delay_ms (1000) ;// Tempo
PORTA = 0b10000010 ;// bit7 AND Bit1 5VDC
delay_ms (100) ;// Tempo
}
Soft_Uart_Write(rec);
}

 

Re: usart pic

up please
 

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…