help sending hex data to pc

General discussion on mikroC.
Post Reply
Author
Message
Mr-H
Posts: 7
Joined: 16 Jul 2011 21:22

help sending hex data to pc

#1 Post by Mr-H » 21 Jul 2011 16:29

hi every body
how to send hexadecimal data from pic to pc using uart
her is my code:

Code: Select all

char trame[4] = {0x04;0x5E;0xA8;0x02};
for(i=0; i<4;i++){
UART1_Write(trame[i]);

}
but i receive different data for example 0x45;0x44;0xdd

please help

ps : im using 16f877a

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: help sending hex data to pc

#2 Post by janko.kaljevic » 22 Jul 2011 12:08

Hello Mr-H,

Check out baud rate of connection.
Baud rate from UART1_Init must be the same as baud rate in USART terminal.

Regards.

Mr-H
Posts: 7
Joined: 16 Jul 2011 21:22

Re: help sending hex data to pc

#3 Post by Mr-H » 22 Jul 2011 21:11

ok I found the solution, in fact my fault was in the declaration of variables, and frequency in which I work

I must declare a variable as follows

Code: Select all

int i;
[color=#FF0040]const [/color]char trame[3] = {0x44,0x77,0xA4,0xBF};
 for(i=0;i<4;i++){
     Uart_Write(trame[i]); // send it
}
another thing, the crystal frequency must be the same as the frequency already compiled into the project (I work with an 8,5268 MHz quartz)

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: help sending hex data to pc

#4 Post by Sparky1039 » 22 Jul 2011 22:13

You use comas to seperate the initialization values.

Code: Select all

char trame[4] = {0x04,0x5E,0xA8,0x02};

Post Reply

Return to “mikroC General”