View previous topic :: View next topic |
Author |
Message |
adrianov
Joined: 09 Mar 2015 Posts: 7
|
Posted: Mon Mar 09, 2015 12:18 pm Post subject: Strange Symbols in my emulator terminal |
|
|
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 |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Mon Mar 09, 2015 2:58 pm Post subject: |
|
|
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 |
|
|
adrianov
Joined: 09 Mar 2015 Posts: 7
|
Posted: Tue Mar 10, 2015 10:59 am Post subject: |
|
|
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 |
|
|
adrianov
Joined: 09 Mar 2015 Posts: 7
|
Posted: Tue Mar 10, 2015 11:32 am Post subject: |
|
|
OK, I have written $crystal = 4915200 and it works well!
Thank you for your help. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Tue Mar 10, 2015 3:16 pm Post subject: |
|
|
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 |
|
|
|