DSPIC & UART Prolem

General discussion on mikroC.
Post Reply
Author
Message
MHI
Posts: 56
Joined: 13 Mar 2010 20:52

DSPIC & UART Prolem

#1 Post by MHI » 20 Mar 2010 18:10

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 1221 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 1221 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..

Sobrietytest
Posts: 619
Joined: 05 Jul 2008 06:05
Location: Thailand

Re: DSPIC & UART Prolem

#2 Post by Sobrietytest » 29 Mar 2010 09:30

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).

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: DSPIC & UART Prolem

#3 Post by tihomir.losic » 08 Apr 2010 10:45

Hello,

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

Best regards,

Losic Tihomir
mikroElektronika [Support team]

Post Reply

Return to “mikroC General”