I am experimenting a dspicPRO 4 board, and I have a little project concerning reception data from a GPS (baud rate =4800), The problem is with the uart reception and transmission.
here is the code:
Code: Select all
void main()
{
PORTD = 0;
TRISD = 0;
trisb=0xff;
ADPCFG = 0xFFFF;
portd=0xFF;
delay_ms(1000);
uart1_init(4800); //transmit to PC
uart2_init(4800); //receive from GPS
uart1_write_char('h');
uart1_write_char('e');
uart1_write_char('l');
uart1_write_char('l');
uart1_write_char('o');
uart1_write_char(10);
uart1_write_char(13);
while(1)
{
PORTD=0x000F;
for (i=0;i<100;i++)
{
while(!uart2_data_ready());
tab[i]=uart2_read_char();
}
PORTD=0x00FF;
delay_ms(1000);
for (i=0;i<100;i++)
{
uart1_write_char(tab[i]);
}
}
}
- the second is that when we enter the second iteration and so on in the while(1) loop, the characters received are the same
And to be more precise, I have connected the GPS serial directly to the PC, and that what I receive with the same configuration of the mikroC terminal. The data received and transmitted by the dspic, should be seen in the same way as illustrated in the second picture.
Please help me, where is my fault ??
Regards
Note: I am using 80 MHZ clock in the mikroC compiler..