Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Bascom Terminal Problem

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

Bascom Member



Joined: 23 Sep 2015
Posts: 22

blank.gif
PostPosted: Wed Sep 23, 2015 3:52 pm    Post subject: Bascom Terminal Problem Reply with quote

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
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Wed Sep 23, 2015 5:23 pm    Post subject: Reply with quote

Try it with avr simulator .... Very Happy Very Happy
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Sep 23, 2015 9:07 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
RWo

Bascom Member



Joined: 23 Sep 2015
Posts: 22

blank.gif
PostPosted: Thu Sep 24, 2015 3:26 am    Post subject: Reply with quote

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
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Thu Sep 24, 2015 4:33 am    Post subject: Reply with quote

With my experimental works tarqueta STK500 not monitor looks like Japanese sign and simulator you work well if the monitor will check and comment .

Embarassed


Last edited by Printpix52 on Thu Sep 24, 2015 4:07 pm; edited 1 time in total
Back to top
View user's profile
Deanus

Bascom Member



Joined: 26 May 2006
Posts: 188
Location: Adelaide

australia.gif
PostPosted: Thu Sep 24, 2015 8:15 am    Post subject: Reply with quote

Hi RWO,
How about posting some code for people to look at and try for you.

Dean
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Sep 24, 2015 8:18 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
RWo

Bascom Member



Joined: 23 Sep 2015
Posts: 22

blank.gif
PostPosted: Thu Sep 24, 2015 2:04 pm    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Sep 24, 2015 2:17 pm    Post subject: Reply with quote

- 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
View user's profile Visit poster's website
RWo

Bascom Member



Joined: 23 Sep 2015
Posts: 22

blank.gif
PostPosted: Thu Sep 24, 2015 3:18 pm    Post subject: Reply with quote

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 Cool and not a lots of challenge to meet. Wasting my offtime with something. No sweat!

Thank to Mark and others
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Sep 24, 2015 3:27 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
RWo

Bascom Member



Joined: 23 Sep 2015
Posts: 22

blank.gif
PostPosted: Thu Sep 24, 2015 3:59 pm    Post subject: Reply with quote

YES it works!Very Happy

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
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Fri Sep 25, 2015 3:03 am    Post subject: Reply with quote

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 !!


Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy
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