Hi,
I have written a program for my ATMega128 on BIGAVR with mikroBasic 4.0.2. The program runs and gets data only when it is sent, but the bytes received are wrong!
Examples:
Sent ASCII '0', received decimal byte 216
Sent ASCII '1', received decimal byte 217
Sent ASCII '2', received decimal byte 216 (again!)
Sent ASCII 'a', received decimal byte 209
Sent ASCII 'b', received decimal byte 208
Sent ASCII 'c', received decimal byte 209 (again!)
etc. The same happens from both a PC as well as from an embedded device that can send ASCII codes on demand. The serial settings are 19200,8,N,1.
An example program that does the above is:
program MTSRead
dim byte1 as byte
dim byteText as string[3]
main:
Glcd_Init(PORTE, 2, 3, 4, 5, 7, 6, PORTA)
Glcd_Set_Font(font5x7, 5, 7, 32)
Glcd_Fill($00)
USart1_Init(19200)
Delay_ms(10)
while (true)
while USart1_Data_Ready = 0
nop
wend
byte1 = USart1_Read
ByteToStr (byte1, byteText)
Glcd_Write_Text(byteText, 1, 0, 1)
delay_ms(2000)
Glcd_Fill($00)
Glcd_Write_Text(" ", 1, 0, 1)
wend
end.