Generic UART not working above 57600

Discussion of issues related to writing ZBasic applications for targets other than ZX devices, i.e. generic targets.
Post Reply
kurakaira
Posts: 77
Joined: 21 March 2007, 1:21 AM
Location: Finland

Generic UART not working above 57600

Post by kurakaira »

Generic targets work great ,,, as long as You keep below ConsoleSpeed of 57600 ... 115200 does not work for my boards , is it a generic target issue or something i have overlooked ?
This affects both the 328P & Mega2560 . . .

Code: Select all

Option TargetDevice ATmega2560 
Option DeviceParameter clockFrequency 16000000 
Option DeviceParameter rtcFrequency 500 
Option DeviceParameter rtcScale 1 
Option DeviceParameter swUartDivisor 8 
Option DeviceParameter swUartMinSpeed 300 
Option DeviceParameter swUartMaxSpeed 19200 
Option DeviceParameter swUartBaseSpeed 2400 
Option DeviceParameter timerSpeed1Divisor 1 
Option DeviceParameter timerSpeed2Divisor 8 
Option DeviceParameter ZBasicBootloader True 

Option ConsoleSpeed 115200  ' 57600 works fine 
Option RTC on 
Option Signon on 
Option TxQueueSize 100 
Option RxQueueSize 40 
Option Console Com1 

Const Led as byte = B.7 

Sub Main() 

Debug.Print "Hello From 2560" 

Do 
Debug.Print "Hello ." 
Call PutPin(Led, 1) 
Call Delay(1.0) 
Call PutPin(Led, 0) 
Debug.Print "It Really Works :)" 
Call Delay(0.5) 
Loop 
End Sub
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Generic UART not working above 57600

Post by dkinzer »

kurakaira wrote:Generic targets work great ,,, as long as You keep below ConsoleSpeed of 57600 ... 115200 does not work for my boards , is it a generic target issue or something i have overlooked ?
At 16MHz, the available divisors cannot produce an accurate baud rate at 115.2K baud and above. The error at 115.2K baud is 2.1%, at 230.4K baud it is 3.5%, and at 460.8K baud it is 8.5%. It should work at 76.8K baud where the error is only 0.2%.

You can see the list of baud rates and error values by using the Target Options dialog, setting the processor frequency, and clicking the Apply button.
- Don Kinzer
Post Reply