View previous topic :: View next topic |
Author |
Message |
gertc
Joined: 06 May 2006 Posts: 88
|
Posted: Sun Nov 20, 2016 12:10 am Post subject: Port Status random in Simulator |
|
|
Hello,
I am making a program showing the status of a Gray code on PortB. I tried to use the Simulator, but the Port status LED's doesn't
change status.
Then I made a simple test
Do
Portb.0 = 1
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 0
Portb.5 = 0
Portb.6 = 0
Portb.7 = 0
Locate 1 , 2
Lcd Portb
Loop
The LCD shows 15, but the PortB LED's that is on is just random. Clicking on any of the other LED's the PortB LED's
again shows another random sequence.
What am I doing wrong?
gerrySC
(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Sun Nov 20, 2016 2:50 am Post subject: |
|
|
Hi,
Did you config portb as output ?
Did you setup lcd ?
If not then default LCD use Portb !!!
you can setup lcd here Menu Options/Compiler/LCD _________________ / Kim |
|
Back to top |
|
|
gertc
Joined: 06 May 2006 Posts: 88
|
Posted: Sun Nov 20, 2016 4:01 pm Post subject: |
|
|
Yes, I am configuring portB as output.
Here is a new test program:
Code: | $regfile = "m1284pdef.dat" 'Microprocessor Type
$crystal = 8000000 ' Frequency 8Mhz
$hwstack = 110 ' default use 32 for the hardware stack
$swstack = 110 ' default use 10 for the SW stack
$framesize = 80 ' default use 40 for the frame space
'$sim
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Portc.7 , Rs = Portc.6
Config Lcd = 16 * 2 'configure lcd screen
Config Portb = Output
Dim Hall As Word
Dim Hall_s As String * 3
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Do
Hall = Getadc(0)
Hall = Hall / 4 'Hall = 0 to 255
Portb = Hall
Hall_s = Str(portb)
Hall_s = Format(hall_s , "000")
Locate 1 , 2
Lcd Hall_s
Waitms 20
Loop |
If I am changing the analog input, the LCD shows the correct value. However, the portB led's only changes if I click on any led in the simulator window. |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Sun Nov 20, 2016 4:18 pm Post subject: |
|
|
Click/enable "Refresh variables" near "Terminal checkbox" on the main bar |
|
Back to top |
|
|
gertc
Joined: 06 May 2006 Posts: 88
|
Posted: Sun Nov 20, 2016 4:37 pm Post subject: |
|
|
Stupid me. How did I miss that.......
Thank you for the reply.
gerrySC |
|
Back to top |
|
|
|