Gopi Vh
Newbie level 4
hi
i used the below code for 18f4520 it was perfectly working ,but its not working in 16f1847 .I am confused what is wrong ,description about the project is
rx/dt -rb1, tx/ck-rb2, if i recieve char it indicates by turning on or off led .
I am using 16f1847 , hc05 bluettoth, android mobile app
i used the below code for 18f4520 it was perfectly working ,but its not working in 16f1847 .I am confused what is wrong ,description about the project is
rx/dt -rb1, tx/ck-rb2, if i recieve char it indicates by turning on or off led .
I am using 16f1847 , hc05 bluettoth, android mobile app
Code:
unsigned char uart_rd;
void main()
{
PORTA =0;
PORTB =0;
ADRESL = 0;
ADRESH = 0;
TRISB = 0;
TRISA = 0;
TRISB.F1 =1;
TRISB.F2 =0;
CM1CON0 = 0;
CM2CON1= 0;
UART1_Init(9600 ); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize*/
while (1)
{
if(UART1_Data_Ready())
{ // If data is received,
uart_rd = UART1_Read();
UART1_Write(uart_rd);
}
Delay_ms(100);
if(uart_rd == 'a')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'b')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'c')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'd')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'e')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'f')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'g')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'h')
{
LATB.F3 = 0;
LATB.F4 = 0;
}
if(uart_rd == 'B')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'C')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'D')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'E')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'F')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'G')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'H')
{
LATB.F3 = 1;
LATB.F4 = 1;
LATA.F7 = 1;
LATA.F6 = 1;
}
if(uart_rd == 'A')
{
LATB.F3 = 1;
LATB.F4 = 1;
}
if(uart_rd == 'S')
{ LATB.F3 = 1;
LATB.F4 = 1;
}
Delay_ms(1000); //RCSTA = 0x00;
}
}
Last edited by a moderator: