View previous topic :: View next topic |
Author |
Message |
RWo
Joined: 23 Sep 2015 Posts: 22
|
Posted: Wed Sep 23, 2015 3:52 pm Post subject: Bascom Terminal Problem |
|
|
Hello,
I'am using todays Bascom Demo on Vista. I'm very happy to find this tool but...
the first test program works but the terminal shows wrong asci.
Does anyone know what is wrong?
Thanks
(BASCOM-AVR version : 2.0.7.5 ) |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Wed Sep 23, 2015 5:23 pm Post subject: |
|
|
Try it with avr simulator .... |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Sep 23, 2015 9:07 pm Post subject: |
|
|
you need to make sure that the processor is actually running at the speed you thin it is.
we have a simple test for that :
config portb=output ' some port or port pin
do
toggle portb
waitms 1000
loop
this code will toggle logic level on port each second. you should measure if that is true. if not, the calculated baud rate will not be right.
another option : test various baud rates in the terminal emulator.
last possible cause : osccal register must be calibrated. have a look at the samples\chip folder for some samples that use osccal. _________________ Mark |
|
Back to top |
|
|
RWo
Joined: 23 Sep 2015 Posts: 22
|
Posted: Thu Sep 24, 2015 3:26 am Post subject: |
|
|
Thanks for your help.
But still it won't work. It seems there is no prob with the Baud or Clock. I receive the exact ammount on chars I've send from the AT.
Just the received chars looking like if there are shifted in the asci table. I have no more idea to get it done. See pic.
|
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Thu Sep 24, 2015 4:33 am Post subject: |
|
|
With my experimental works tarqueta STK500 not monitor looks like Japanese sign and simulator you work well if the monitor will check and comment .
Last edited by Printpix52 on Thu Sep 24, 2015 4:07 pm; edited 1 time in total |
|
Back to top |
|
|
Deanus
Joined: 26 May 2006 Posts: 188 Location: Adelaide
|
Posted: Thu Sep 24, 2015 8:15 am Post subject: |
|
|
Hi RWO,
How about posting some code for people to look at and try for you.
Dean |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Thu Sep 24, 2015 8:18 am Post subject: |
|
|
and beside the test code, you should give more info about your hardware. how you connected the tx/rx to the PC is important. _________________ Mark |
|
Back to top |
|
|
RWo
Joined: 23 Sep 2015 Posts: 22
|
Posted: Thu Sep 24, 2015 2:04 pm Post subject: |
|
|
Ok,
the code is no secret. It's just somthing to test and learn about bascom for first time.
Now, I use a AVR_Board2014 with ATMega32 16PU, a Satellite Laptop with Vista. I reinstall the com driver (com4) and Bascom Demo. I test the AVR also on my old desktop with mkt-terminal. All has the same result. The chars are switch form Print "01234" to "pqrst" in the terminal.
I can't find the problem. Thanks for your efforts
ps. sorry for some mother tongue comments in the source
Code: | '-----------------------------------------------------------------------------------------
'Programm: TEST
'Hardware: ATMega32, AVR_Board2014
'Autor : R.Wo
'-----------------------------------------------------------------------------------------
'Konstanten ______________________________________________________________________________
Const Null = 0
'Einbinden _______________________________________________________________________________
DECLARE SUB DoTimerEvents
'Hardware INT ____________________________________________________________________________
$Regfile = "m32def.dat"
$Crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
$baud = 19200
'Globale VAR's ___________________________________________________________________________
Dim W As Word , Channel As Byte
W = 0 : Channel = 0
Dim TIntCount As Byte , Fms As Byte , ByteComp as Byte
TIntCount = 0 : Fms = 0
Dim Loop4 as Byte
Loop4 = 0
Dim vByte as Byte , iByte as Byte , sByte as String * 4
vByte = 0 : iByte = 0 : sByte = ""
'Kommunikation ___________________________________________________________________________
Config Com1 = Dummy , Synchrone = 0 , Parity = none , Stopbits = 1 , Databits = 8 _
Clockpol = 1
'Interrupts ______________________________________________________________________________
Config Timer0 = Timer , Prescale = 1024
On Ovf0 Tim0_isr 'TIMER0 als OVF0 geht auch
Enable Timer0
'AD-Wandler ______________________________________________________________________________
Config Adc = SINGLE , PRESCALER = AUTO , REFERENCE = INTERNAL
'Display _________________________________________________________________________________
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , _
E = Porta.3 , Rs = Porta.2
Config Lcd = 16 * 2
Config Portb = Output 'Hintergrundlicht
'Freigaben release _______________________________________________________________________
Start Adc 'AD-Wandler Power ein A0, A1
Set Portb.3 : Cls : Cursor Off Noblink 'LCD Hintergrunglicht, Löschen, Cursor
Lcd "Channel 0 Off " 'LCD static Text
Lowerline ' ""
Lcd "Value " ' "
Enable Interrupts 'IRs Freigabe
'MAIN ====================================================================================
Do
W = Getadc(channel)
'( iByte = Ischarwaiting() 'Empfange Zeichen
If iByte = 1 Then 'we got something
iByte = Waitkey()
sByte = chr(iByte)
Print sByte
Print iByte
Print chr(144)
locate 1 , 13 : lcd " "
locate 1 , 13 : lcd iByte
iByte = 0
sByte = ""
end if
')
If Fms.0 = 1 then Call DoTimerEvents
Loop
'SUBs ____________________________________________________________________________________
Sub DoTimerEvents
'
Reset Fms.0 '0,05 sec
If Fms.2 = 1 then '0,20 sec
Reset Fms.2
locate 2 , 9 : lcd " "
locate 2 , 9 : lcd W
End If
If Fms.4 = 1 then '1,00 sec
Reset Fms.4
Print "01234" '???? Receive in terminal>> pqrst
'Print "Channel " ; Channel ; " Value " ; W
locate 1 , 13
Select Case Loop4
Case 0 : lcd "1 "
Case 1 : lcd "2 "
Case 2 : lcd "3 "
Case 3 : lcd "4 "
End Select
Incr Loop4 : If Loop4 > 3 then Loop4 = 0
End If
End SUB
'Interrupts ______________________________________________________________________________
Tim0_isr: 'Timer0
'
Incr TIntCount : ByteComp = TIntCount mod 4
If ByteComp = Null then
Set Fms.0 '0,05 sec
ByteComp = TIntCount mod 8 : If ByteComp = Null then Set Fms.1 '0,10 sec
ByteComp = TIntCount mod 16 : If ByteComp = Null then Set Fms.2 '0,20 sec
ByteComp = TIntCount mod 40 : If ByteComp = Null then Set Fms.3 '0,50 sec
ByteComp = TIntCount mod 80 : If ByteComp = Null then Set Fms.4 '1,00 sec
ByteComp = TIntCount mod 160 : If ByteComp = Null then Set Fms.5 '2,00 sec
End If
If TIntCount >= 160 then TIntCount = Null
Return
End |
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Thu Sep 24, 2015 2:17 pm Post subject: |
|
|
- how are your fuse bits set?
when you try something, keep the code simple :
Code: | $Regfile = "m32def.dat"
$Crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
$baud = 19200
Config Com1 = Dummy , Synchrone = 0 , Parity = none , Stopbits = 1 , Databits = 8 _
Clockpol = 1
do
print "this is a test"
waitms 1000
loop |
- make sure the baud in the terminal is indeed 19200 and that the oscillator speed indeed is 16000000
- make sure there is no clock division fuse bit set (when the m32 has this option)
- it would be handy to see the circuit of your board.
another simple code:
dim b as byte
do
b=waitkey()
print b
loop
this would show the ascii code of a pressed key. pressing A would give 65.
also verify of the code was uploaded correct to the processor. _________________ Mark |
|
Back to top |
|
|
RWo
Joined: 23 Sep 2015 Posts: 22
|
Posted: Thu Sep 24, 2015 3:18 pm Post subject: |
|
|
Thanks your replay
Terminal baud 16200 seems ok. But with >>the oscillator speed indeed is 16000000<< I have doubt.
I can't post the circuit diagramm cause of unknown copy right. The external cristal, Q2 on pins 12,13 says 14,7456MHz . Is this pehaps my problem?
"Config CLOCKDIV = 1" is not aceppted by the compiler.
I don't have much expierence in Basic, but I like to find a way to have a code witch is not waiting for external events e.g. b=waitkey() this stoping the code execution so far.
As I sad before, the code is just to get a taste of Bascom. I'm close to pension and not a lots of challenge to meet. Wasting my offtime with something. No sweat!
Thank to Mark and others |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Thu Sep 24, 2015 3:27 pm Post subject: |
|
|
yes that is your problem !
your code should have : $crystal= 14745600
that is, if you have read the crystal value correct.
$crystal informs the compiler about the oscillator speed, it can not influence your hardware. so it would not set your hardware to 16 Mhz !
i advise to check the simple samples from the samples folder. also read the pdf manual to get an idea of what is possible and what isn't.
instead of waitkey you can use inkey, press F1 and you get help. _________________ Mark |
|
Back to top |
|
|
RWo
Joined: 23 Sep 2015 Posts: 22
|
Posted: Thu Sep 24, 2015 3:59 pm Post subject: |
|
|
YES it works!
Thank you Mark!
The funny thing is, I received some sample code for this board with 16MHz configuerd. So is was never working before.
That teach me to ceck the complete package next time, before starting get lost in code making.
mmm, where are the sample folders? They don't come with the demo. |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Fri Sep 25, 2015 3:03 am Post subject: |
|
|
Hello everyone !!!! already work well with my tarqueta STK500 real monitor and simulator bascom all works fine and the need to establish fuse .
· Select the “Lock and Fuse Bits” tab and maximize the programmer window.
· Check if you see the following in the “Fusebit” section:
"1:Divide Clock by 8 Disabled"
"Int. RC Osc. 8 MHz; Start-up time: X CK + X ms; [CKSEL=XXXX SUT=XX]"
Thank you very much and am learning more ...... greetings !!
|
|
Back to top |
|
|
|