View previous topic :: View next topic |
Author |
Message |
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Mon Apr 11, 2011 10:22 pm Post subject: Hardware Simulator problem |
|
|
I know it's probably something I'm doing wrong but consider the following code:
Code: |
$regfile = "m2560def.dat"
$hwstack = 2000
$swstack = 600
$framesize = 500
$crystal = 16000000
$baud = 57600
$baud1 = 57600
Dim A As Byte
Config PORTC = Output
For A = 0 to 7
Toggle PORTC.A
Wait 1
Next
|
Should I not see Port C's "LEDS" in the Hardware simulation window toggle through the LEDS? I'm seeing the code itself stepping through ok but the "LEDS" don't do anything |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Apr 11, 2011 10:28 pm Post subject: |
|
|
yes it should and it does (for me).
i would use 0 to 7 instead of 1 to 8.
if you use a bigger range you will write to the location after the portc register. _________________ Mark |
|
Back to top |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Mon Apr 11, 2011 10:35 pm Post subject: |
|
|
Yes, I caught the 0 to 7 change however that exact code is NOT working for me.
Bascom 4.0.2.0 running under Win 7 |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 9:41 am Post subject: |
|
|
I have not been using the hardware simulator but ran the program to see what happend, no simulated leds! so then I ran
'name : port.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: PortB and PortD
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
Same no leds light up
So then tried
Config Pinb.2 = Output 'enable port as output
Config Pinb.1 = Output
Config Pinb.0 = Output
Set Portb.0
Set Portb.1
Set Portb.2
still no leds?
This was just to have a look at the simulator.
basacom avr 2.0.4.0 windows XP up to date. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Apr 12, 2011 10:22 am Post subject: |
|
|
you need to include $regfile with the processor.
I use vista but can not imagine that it does not work.
when you monitor the portb variable, does it show the proper value?
further, i assume you step through the code using F8? _________________ Mark |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 10:37 am Post subject: |
|
|
This does not light any leds this is the whole program I thought that using a simple program would be the best way to test it
$regfile = "m48def.dat" 'Using the Mega48
$crystal = 8000000
'$crystal = 1000000 'Using the internal RC at 8 meg
$baud = 19200
Config Pinb.2 = Output 'enable port as output
Config Pinb.1 = Output
Config Pinb.0 = Output
Set Portb.0
Set Portb.1
Set Portb.2
End |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 10:49 am Post subject: |
|
|
Ok if I go and select a port in the variables it lights up the leds then if I end bascom then start it again try the simulator no leds but select a port again they light up even though the variable is showing 00000111 |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 11:04 am Post subject: |
|
|
Ran kens program same result if I go and select portc variable it shows the result but not as the program is running even said 0 to 3 instead of 0 to 7 to see if I get 4 leds and yes 4 leds. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 11:28 am Post subject: |
|
|
Made some changes to kens program to watch it on the lcd and the 0s changed to 1s as the variable A advanced but the leds did not change
$regfile = "m2560def.dat"
$hwstack = 2000
$swstack = 600
$framesize = 500
$crystal = 16000000
$baud = 57600
$baud1 = 57600
Dim A As Byte
Config Portc = Output
For A = 0 To 7
Locate 1 , 1
Lcd A
Locate 2 , 1
Lcd Bin(portc)
Toggle Portc.a
Wait 1
Cls
Next
End |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 11:33 am Post subject: |
|
|
further, i assume you step through the code using F8?
So do the leds only work when you step through the program? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Apr 12, 2011 11:46 am Post subject: |
|
|
If you press RUN/F5 , your code will be executed and stopped before you know it. In your case there is NO END, and it will be unpredictable what happens.
You should use a do .. loop to watch the effect. Or at least put an END after your code.
When you step/F8, the variables will be updated after each executed step.
If you use run, this will only happen when you press 'refresh variables'.
This is done to make simulation perform better. _________________ Mark |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Apr 12, 2011 12:09 pm Post subject: |
|
|
When you step/F8, the variables will be updated after each executed step.
If you use run, this will only happen when you press 'refresh variables'.
This is done to make simulation perform better.
I have now learnt something I did not know before! |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Apr 12, 2011 12:26 pm Post subject: |
|
|
have a look in the help, there is plenty to learn.
from the help :
The refresh variables button will refresh all variables during a run (F5). When you use the hardware simulator, the LEDS will only update their state when you have enabled this option. Note that using this option will slow down simulation. That is why it is an option. When you use F8 to step through your code you do not need to turn this option on as the variables are refreshed after each step. _________________ Mark |
|
Back to top |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Tue Apr 12, 2011 3:47 pm Post subject: |
|
|
So Mark.....
LEDS don't work for me. What should I have a look at to help ID the problem? |
|
Back to top |
|
|
|