开发者

An issue with uart and pic 18f452

开发者 https://www.devze.com 2023-03-21 05:19 出处:网络
i have a problem with pic18f452 and uart i use simplest code like that: UART1_Init(9600);// Initialize UART module at 9600 bps

i have a problem with pic18f452 and uart i use simplest code like that:

 UART1_Init(9600);              // Initialize UART module at 9600 bps
 Delay_ms(100);                 // Wait for UART module to stabilize

and between forever while loop i have this code

  UART1_Write_Text("HELLO2");
  Delay_ms(1000);

also i have in my hardware lcd module it works very fine but my received data on pc is a scrap like that

???m

i have checked all connection sothand time nothing wrong al开发者_Go百科so i have changed MAX232 ic but with no luck ?! my hardware is like that

An issue with uart and pic 18f452

finall all my connections are ok (polarity and every thing else ?) EDIT : i use mikroc as a compiler


Looks like a baud rate error. Have you checked that your oscillator settings are resulting in the expected frequency? Does the serial library you are using expect a certain clock frequency and you are sure that you are running at that frequency, or does it work over a set of frequencies and you have correctly informed the serial library what frequency you are using? Also it would be useful to see the byte received as a decimal or hex number rather than just ASCII.


What about the start bits, number of data bits, parity, and stop bits? Are they the same on both ends?


It happens when you have loose connections i.e. from max 232 to Pic & from max 232 to PC. Try checking the fluctuations over the transmit pin or usr Oscilloscope to see the ASCII values of Hello World alphabets.

0

精彩评论

暂无评论...
验证码 换一张
取 消