Page 1 of 1

DSPIC & UART Prolem

Posted: 20 Mar 2010 18:10
by MHI
Hello All

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]);
}
}
}
I have uploaded the screen shot of the mikroC terminal, i can figure out that there is 2 different problems :roll: :
hyper terminal picture
hyper terminal picture
uart.JPG (63.91 KiB) Viewed 1267 times
- the first is the characters received from the GPS have an unknown format
- 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.
gps.JPG
gps.JPG (69.79 KiB) Viewed 1267 times
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..

Re: DSPIC & UART Prolem

Posted: 29 Mar 2010 09:30
by Sobrietytest
It looks like you have a baud rate incompatibity, can you tell us which PIC you are using and what the oscillator settings are? (The baud rate generator in the PIC is dependant on the oscillator settings).

Re: DSPIC & UART Prolem

Posted: 08 Apr 2010 10:45
by tihomir.losic
Hello,

please, tell me, which microcontroller are you using?
I need that information in order to inspect your project.

Best regards,

Losic Tihomir