View previous topic :: View next topic |
Author |
Message |
StSch
Joined: 08 Feb 2015 Posts: 8 Location: Heilbronn, Germany
|
Posted: Sun Feb 08, 2015 10:51 am Post subject: Only hieroglyphic text in Terminal emulator |
|
|
I am a total beginner and have a problem with a sample program of an assembly kit I have bought. See attachment for details. I only see hieroglyphic text in the Terminal emulator. Any idea what the reason could be and how to fix it?
Best wishes from South-Germany,
Steffen
(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: Sun Feb 08, 2015 12:08 pm Post subject: |
|
|
Hi,
Check the fuse bits for the AVR. Are you sure it's actually running at 8MHz (Maybe it's running with the 8MHz RC but with Clock DIV8 set).
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Sun Feb 08, 2015 12:17 pm Post subject: |
|
|
Welcome to this friendly forum and to the world of bascom!
The good news: If it's your first attempt ever to print something from a micro to a PC, seeing crap is better than seeing nothing, at least....
Seeing crap is usualy a sign for having trouble with timing and frequencies.
$crystal = 8000000 tells the compilier to what frequ you have set your micro, it does not set the micro itself! Be aware of that fact!
The micros freq is set by the fusebits, do you know how to handle the fusebits?
The first check after setting up a new hard- and software ist always a simple loop that toggles a led every second.
With a stopwatch in my hand I count the blinks in a minute, then I'm shure everything is OK.
Try this and report!
Marc |
|
Back to top |
|
|
StSch
Joined: 08 Feb 2015 Posts: 8 Location: Heilbronn, Germany
|
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Feb 08, 2015 3:17 pm Post subject: |
|
|
The internal RC-oscillator isn't precise enough for UART.
As well your test's resolution is not very high, you can try with:
$crystal = 8533333 |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Feb 08, 2015 3:30 pm Post subject: |
|
|
hello,
Do you use a bootloader ?
if not continue to read
What kind of programmer do you use ?
if you use a ISP with a 10 pins connectors
add after the "End" of your program: this line program the fusebits for à Mega168, I hope it is a same for the 88 it is the same familly.
$prog &HFF , &HE2 , &HDF , &HF9 ' generated. Take care that the chip supports all fuse bytes.
then try your program again
Is the serial emulator as a good setting ?
Bon courage
JP |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Feb 08, 2015 3:35 pm Post subject: |
|
|
instead of changing the fuse bits you can best start with CONFIG CLOCKDIV=1
this will set the internal divider to 1 so you get the right frequency on most chips.
A baud of 19200 will do nice in most cases. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Feb 08, 2015 4:07 pm Post subject: |
|
|
albertsm wrote: | instead of changing the fuse bits you can best start with CONFIG CLOCKDIV=1
this will set the internal divider to 1 so you get the right frequency on most chips. |
He does not need to change the CKDIV8 fuse, he gets 32 blinks in his test code, which shows a) the CKDIV8 fuse is not set and b) the internal RC is off by nearly 7 percent, which is too much. It can be compensated with OSCCAL, or by setting the actual frequency for crystal, which is then used for calculation of the UART baud rate. |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Sun Feb 08, 2015 8:04 pm Post subject: |
|
|
Suggestion for a simple try:
If you have more samples of the micro, swap them and count blinks until you find one with 30 blinks.
MWS concern about the precision of the the internal RC is only half the truth, in fact I use a lot of micros running on the interal RC and having the uart working. Most micros offer a reg oscal to trim the internal RC. We could discuss that later if nessesary.
For now I Think you are just unlucky to have a micro that is 7% off from the shelf....
The uart should work at 2% deviation. (My experience). |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Feb 08, 2015 9:05 pm Post subject: |
|
|
Arera wrote: | If you have more samples of the micro, swap them and count blinks until you find one with 30 blinks. |
Hmm, considering many ways lead to Rome, but that's a nonsense suggestion.
Why the TO should exchange micros, when all that's needed, is to change $crystal, recompile and let Bascom calculate and set the baud rate register accordingly?
Quote: | MWS concern about the precision of the the internal RC is only half the truth |
In case the deviation in clock frequency is the culprit, it's actually the full truth.
The internal RC is unsuitable for reliable serial communication, if it works in some cases, it won't work in others.
For hobby and uncritical use the RC can be made to work, but it's simply not recommendable, as more a crystal or ceramic resonator is only a question of a few cents.
One more issue may be a wrong baud rate setting of the terminal, however I would already take care, that the baud rate is set correctly in the Windows system settings. |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Sun Feb 08, 2015 9:12 pm Post subject: |
|
|
MWS, my attept is to help an absolute beginner to a first success the most simple way one can think of. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Feb 08, 2015 9:42 pm Post subject: |
|
|
while you can change the $crystal value when the clock divisor is correct, you can also change the osccal register.
This is from the samples'\chips\mega88.bas sample :
Code: | '--------------------------------------------------------------
' mega88.bas
' mega88 sample file
' (c) 2004, MCS Electronics
'--------------------------------------------------------------
$regfile = "m88def.dat"
$crystal = 8000000
$baud = 19200
$hwstack = 40
$swstack = 40
$framesize = 40
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Const I_know_osccal = 0 'make 0 or 1
Config Clockdiv = 1 'we want 8 Mhz
Config Portb = Output
'execute following code only when osccal value is unknown
#if I_know_osccal <> 1
For Osccal = &HA0 To &HB0 'in worse case try from 0 to 255
Print "Wait for this to be readable... " ; Hex(osccal)
Waitms 500
Next
#endif
'when you know the value , you can set it directrly
'Osccal = &HAF
'the calibration value was &HAD
|
while you can also change the $crystal value, the osccal register is suited for it. when you display the values you can chose the value which shows the best result for the uart output.
the best output for the uart does not need to mean that it is also to most precise value for the oscillator, but in this case we want good output on the terminal.
I programmed many m88 chips with bootloader and it depended on batches of they all would work correct or that they required a change of osccal. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Feb 08, 2015 10:14 pm Post subject: |
|
|
Arera wrote: | MWS, my attept is to help an absolute beginner to a first success the most simple way one can think of. |
The most simple way, also for a beginner, is to edit $crystal, recompile and flash the controller.
It can be immediately checked by the blink-method.
Suggesting in contrary to change controllers, where a beginner usually doesn't have a bunch in stock, is pretty narrow-sighted.
If that's the most simple way you can think on, I suggest you work on your imagination. |
|
Back to top |
|
|
Dave
Joined: 05 Feb 2005 Posts: 314 Location: OR
|
Posted: Mon Feb 09, 2015 1:36 am Post subject: |
|
|
Mark,
I changed to $crystal = 7372800 and $baud = 115200 in your code. We may as well calibrate the internal oscillator run at a frequency that has 0% error for most baud rates.
Steffen,
If you try this make sure to set your terminal baud rate to 115200.
You might have to edit this line:
For Osccal = &HA0 To &HB0 'in worse case try from 0 to 255
I normally use 1 to 127.
Code: | '--------------------------------------------------------------
' mega88.bas
' mega88 sample file
' (c) 2004, MCS Electronics
'--------------------------------------------------------------
$regfile = "m88def.dat"
'$crystal = 8000000
$crystal = 7372800
'$baud = 19200
$baud = 115200
$hwstack = 40
$swstack = 40
$framesize = 40
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Const I_know_osccal = 0 'make 0 or 1
Config Clockdiv = 1 'we want 8 Mhz
Config Portb = Output
'execute following code only when osccal value is unknown
#if I_know_osccal <> 1
For Osccal = &HA0 To &HB0 'in worse case try from 0 to 255
Print "Wait for this to be readable... " ; Hex(osccal)
Waitms 500
Next
#endif
'when you know the value , you can set it directrly
'Osccal = &HAF
'the calibration value was &HAD
|
|
|
Back to top |
|
|
StSch
Joined: 08 Feb 2015 Posts: 8 Location: Heilbronn, Germany
|
Posted: Mon Feb 09, 2015 3:50 am Post subject: |
|
|
MWS wrote: | You can try with:
$crystal = 8533333 |
This works for me. Now the text is displayed properly in the terminal emulator.
8533333 = 8000000 + 6,66% (from the LED blink ratio; 2 * 100 / 30), right? It also works with 1 * 100 / 30 = 3,33 and $crystal = 8266666 (8000000 + 3,33%). But definitely not with $crystal = 8000000 which I have tried again. |
|
Back to top |
|
|
|