Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Strange Symbols in my emulator terminal

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
adrianov

Bascom Member



Joined: 09 Mar 2015
Posts: 7

PostPosted: Mon Mar 09, 2015 12:18 pm    Post subject: Strange Symbols in my emulator terminal Reply with quote

Hi everyone,
I would like to show on bascom terminal emulator the lines declared on the program file with “Print” command, I can see strange symbols on the terminal but I can’t understand anything.
To establish UART protocol between my PC and my ATmega48 I use a “mysmartusb MK3” in direct-communication mode. I tried to change the baudrate but still doesn’t working. Really I don’t know how determinate the baudrate.
Could you help me?

(BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Mon Mar 09, 2015 2:58 pm    Post subject: Reply with quote

Hello,

You appear to be missing the $Crystal= command (that tells the Compiler what speed the AVR is running at) and $baud= also to tell the Compiler what Baudrate to use for Serial comms.

Fix both of them and try again.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
adrianov

Bascom Member



Joined: 09 Mar 2015
Posts: 7

PostPosted: Tue Mar 10, 2015 10:59 am    Post subject: Reply with quote

Hello,
I have written the baud and crystal command:
$crystal = 4000000
$baud = 19200
Still not working
I have an external oscillator of 4.9152 MHz, I don't know if value of crystal have to be identical to external oscillator.

what's your opinion?
Thank you very much!
Back to top
View user's profile
adrianov

Bascom Member



Joined: 09 Mar 2015
Posts: 7

PostPosted: Tue Mar 10, 2015 11:32 am    Post subject: Reply with quote

OK, I have written $crystal = 4915200 and it works well!
Thank you for your help.
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Tue Mar 10, 2015 3:16 pm    Post subject: Reply with quote

Hello,

The $Crystal directive needs to be the actual frequency that the AVR is running at. On AVR's the clock used to generate the serial communication runs at a fraction of the main clock (this fraction needs to be calculated by the compiler and written in the correct registers).

Lets say to CPU is running at 3.68MHz and you want a baud rate of 9600baud the compiler must calculate what divider should be used to generate the correct clock frequency for the serial port, if you enter the wrong crystal frequency the compiler will calculate the wrong divider and your baud rate will not be correct.

But it's good to see the problem is solved, have fun with your AVR.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum