Hi,
I have a problem getting some pins on the arduino Mega board I'm using to simply toggle on-off.
I set them as outputs and use the "SET" and "RESET" commands to toggle the pins.
But for some reason I get strange results on some of the pins and/or no output on some of them.
Here is the pins I have problem with, and their results from a quick test program I wrote to debug the issue:
PinB.4 Toggles every second loop.
PinH.6 Does not output (stays low).
PinH.5 Does not output (stays low).
PinH.4 Does not output (stays low).
PinH.3 Toggles fine.
PinG.5 Toggles every second loop
PinC.5 Does not output (stays low).
PinC.7 Toggles fine.
PinA.6 Does not output (stays low).
PinA.4 Does not output (stays low).
PinA.2 Does not output (stays low).
PinA.0 Toggles fine.
The program just toggles these pins every 1 second, so the result can be seen with some LEDs.
Any suggestions? I'm using Bascom 2.0.7.7
[code:1:76019d2da5]
$regfile = "m1280def.dat"
$crystal = 16000000
$baud = 250000
$hwstack = 128
$framesize = 128
$swstack = 128
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portl.4 , Db5 = Portl.6 , Db6 = Portg.0 , Db7 = Portg.2 , Rs = Portl.0 , E = Portl.2
dim Direction_low as Byte
dim Direction_high as Byte
Config Porta = Output
Config Portb = Output
Config Portc = Output
Config Portd = Output
Config PortH = Output
Config PortG = Output
Config Pinb.4 = Output '1
Config Pinh.6 = Output '2
Config Pinh.5 = Output '3
Config Pinh.4 = Output '4
Config Pinh.3 = Output '5
Config Ping.5 = Output '6
Config Pinc.5 = Output '7
Config Pinc.7 = Output '8
Config Pina.6 = Output '9
Config Pina.4 = Output '10
Config Pina.2 = Output '11
Config Pina.0 = Output '12
Dout1 Alias Pinb.4 : Ddrb.4 = 1
Dout2 Alias Pinh.6 : Ddrh.6 = 1
Dout3 Alias Pinh.5 : Ddrh.5 = 1
Dout4 Alias Pinh.4 : Ddrh.4 = 1
Dout5 Alias Pinh.3 : Ddrh.3 = 1
Dout6 Alias Ping.5 : Ddrg.5 = 1
Dout7 Alias Pinc.5 : Ddrc.5 = 1
Dout8 Alias Pinc.7 : Ddrc.7 = 1
Dout9 Alias Pina.6 : Ddra.6 = 1
Dout10 Alias Pina.4 : Ddra.4 = 1
Dout11 Alias Pina.2 : Ddra.2 = 1
Dout12 Alias Pina.0 : Ddra.0 = 1
'-----------------------------------------------
Do
Direction_low.0 = 1
Direction_low.1 = 0
Direction_low.2 = 1
Direction_low.3 = 0
Direction_low.4 = 1
Direction_low.5 = 0
Direction_low.6 = 1
Direction_low.7 = 0
Direction_high.0 = 1
Direction_high.2 = 0
Direction_high.3 = 1
Direction_high.4 = 0
locate 1,1
LCD Direction_low.0
LCD " "
LCD Direction_low.1
LCD " "
LCD Direction_low.2
LCD " "
LCD Direction_low.3
LCD " "
LCD Direction_low.4
LCD " "
LCD Direction_low.5
locate 2,1
LCD Direction_low.6
LCD " "
LCD Direction_low.7
LCD " "
LCD Direction_high.0
LCD " "
LCD Direction_high.1
LCD " "
LCD Direction_high.2
LCD " "
LCD Direction_high.3
Dout1 = Direction_low.0
Dout2 = Direction_low.1
Dout3 = Direction_low.2
Dout4 = Direction_low.3
Dout5 = Direction_low.4
Dout6 = Direction_low.5
Dout7 = Direction_low.6
Dout8 = Direction_low.7
Dout9 = Direction_high.0
Dout10 = Direction_high.1
Dout11 = Direction_high.2
Dout12 = Direction_high.3
wait 1
Direction_low.0 = 0
Direction_low.1 = 1
Direction_low.2 = 0
Direction_low.3 = 1
Direction_low.4 = 0
Direction_low.5 = 1
Direction_low.6 = 0
Direction_low.7 = 1
Direction_high.0 = 0
Direction_high.2 = 1
Direction_high.3 = 0
Direction_high.4 = 1
locate 1,1
LCD Direction_low.0
LCD " "
LCD Direction_low.1
LCD " "
LCD Direction_low.2
LCD " "
LCD Direction_low.3
LCD " "
LCD Direction_low.4
LCD " "
LCD Direction_low.5
locate 2,1
LCD Direction_low.6
LCD " "
LCD Direction_low.7
LCD " "
LCD Direction_high.0
LCD " "
LCD Direction_high.1
LCD " "
LCD Direction_high.2
LCD " "
LCD Direction_high.3
Dout1 = Direction_low.0
Dout2 = Direction_low.1
Dout3 = Direction_low.2
Dout4 = Direction_low.3
Dout5 = Direction_low.4
Dout6 = Direction_low.5
Dout7 = Direction_low.6
Dout8 = Direction_low.7
Dout9 = Direction_high.0
Dout10 = Direction_high.1
Dout11 = Direction_high.2
Dout12 = Direction_high.3
'Config Pinb.4 = Output '1
'Config Pinh.6 = Output '2
'Config Pinh.5 = Output '3
'Config Pinh.4 = Output '4
'Config Pinh.3 = Output '5
'Config Ping.5 = Output '6
'Config Pinc.5 = Output '7
'Config Pinc.7 = Output '8
'Config Pina.6 = Output '9
'Config Pina.4 = Output '10
'Config Pina.2 = Output '11
'Config Pina.0 = Output '12
wait 1
Loop
End
[/code:1:76019d2da5]
Thanks
Thanos
[b:76019d2da5][color=red:76019d2da5](BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.6 )[/b:76019d2da5][/color:76019d2da5]
↧