Hi,
Let me preface this thread by stating that I have done a search for '#include' and have come up empty. That being said, if this has been discussed, please feel free to point me in the right direction - Thank You.
My query:
I have a 18M2 hooked up to a MAX7219 chip which is driving two 4X7 segment LED display modules.
If I load the following program into it, with the following .basinc file in the same directory as the .bas program:
everything works fine - the displays self test briefly and then display the digits 1 through 8 on the respective LEDS.
Now, if I move the 'SHIFT_TO_7219' subroutine from the end of the .bas program file and place it at the end of the .basinc file (message length limitations prevent me from quoting the code again), then the MAX7219 initializes fine, does the brief all segments lit self test, but does NOT display the digits 1 through 8 ?? The displays remain blank...
The manual states that the #include directive is not yet implemented, but I've read on here that it actually is - and PE 6.0.8.1 has no issue with it.
I'm stumped as to why this doesn't work when the sub is in the .basinc file. If the #include imports code into the .bas file, then shouldn't the sub be there and work??
Stumped ??
Regards, John.
Let me preface this thread by stating that I have done a search for '#include' and have come up empty. That being said, if this has been discussed, please feel free to point me in the right direction - Thank You.
My query:
I have a 18M2 hooked up to a MAX7219 chip which is driving two 4X7 segment LED display modules.
If I load the following program into it, with the following .basinc file in the same directory as the .bas program:
Code:
[color=Green]'Program file:'[/color]
[color=Navy]#include [/color][color=Red]"Max7219 Demo Include.basinc"[/color]
[color=Green][PLAIN]'-----[ Program Code ]-----------------------------------------------------[/PLAIN]
[/color][color=Blue]for [/color][color=Black]temp [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]8
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Black]temp
Value [/color][color=DarkCyan]= [/color][color=Black]temp
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Blue]next
end
[/color]
[color=Green][PLAIN]' -----[ Subroutines ]-----------------------------------------------------[/PLAIN]
'Shift data to MAX7219 sub:[/color]
[color=Black]SHIFT_TO_7219:
[/color][color=Blue]for [/color][color=Purple]b4 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]to [/color][color=Navy]7 [/color][color=Green]'shift 1st 8 bits (Register)
[/color][color=Purple]b5 [/color][color=DarkCyan]= [/color][color=Black]Register [/color][color=DarkCyan]and [/color][color=Navy]128 [/color][color=Green]'Mask MSB
[/color][color=Blue]low [/color][color=Black]dta
[/color][color=Blue]if [/color][color=Purple]b5 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]then [/color][color=Black]SKIP
[/color][color=Blue]high [/color][color=Black]dta
SKIP: [/color][color=Blue]pulsout [/color][color=Black]clk, [/color][color=Navy]1
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Black]Register [/color][color=DarkCyan]* [/color][color=Navy]2 [/color][color=Green]'Shift left 1 bit
[/color][color=Blue]next
[/color][color=Green]'low dta
[/color][color=Blue]for [/color][color=Purple]b4 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]to [/color][color=Navy]7 [/color][color=Green]'shift 2nd 8 bits (Value of Register)
[/color][color=Purple]b5 [/color][color=DarkCyan]= [/color][color=Black]Value [/color][color=DarkCyan]and [/color][color=Navy]128
[/color][color=Blue]low [/color][color=Black]dta
[/color][color=Blue]if [/color][color=Purple]b5 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]then [/color][color=Black]SKIP_AGAIN
[/color][color=Blue]high [/color][color=Black]dta
SKIP_AGAIN: [/color][color=Blue]pulsout [/color][color=Black]clk, [/color][color=Navy]1
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Black]Value [/color][color=DarkCyan]* [/color][color=Navy]2
[/color][color=Blue]next
[/color][color=Green]'low dta
[/color][color=Blue]pulsout [/color][color=Black]load, [/color][color=Navy]1
[/color][color=Blue]return[/color]
Code:
[color=Green]'Include file:'[/color]
[color=Navy]#picaxe [/color][color=Black]14m2[/color]
[color=Navy]#no_data[/color]
[color=Blue]setfreq m8 [/color][color=Green]'increase default M2 freq of 4 MHz to 8 MHz for quicker display response
[/color][color=Blue]symbol [/color][color=Black]dta [/color][color=DarkCyan]= [/color][color=Blue]B.1
symbol [/color][color=Black]clk [/color][color=DarkCyan]= [/color][color=Blue]B.2
symbol [/color][color=Black]load [/color][color=DarkCyan]= [/color][color=Blue]B.3
symbol [/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Purple]b10
[/color][color=Blue]symbol [/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Purple]b11
[/color][color=Blue]symbol [/color][color=Black]temp [/color][color=DarkCyan]= [/color][color=Purple]b12
[/color]
[color=Green][PLAIN]' -----[ Initialization ]--------------------------------------------------[/PLAIN]
'Initialize 7219:
[/color][color=Blue]low [/color][color=Black]dta
[/color][color=Blue]low [/color][color=Black]clk
[/color][color=Blue]low [/color][color=Black]load
[/color][color=Green]'Set Decode Mode
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]9 [/color][color=Green]'B type decode for all digits
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]255
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Green]'set intensity level to 5 (from 0-15)
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]$A
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]5
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Green]'Set Scan Limit (No. of digits: 0-7 = 1 to 8 digits)
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]$B
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]7
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Green]'Set Digit Test mode (0=Normal, 1=Test)
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]$F
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]1
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Blue]wait [/color][color=Navy]1
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]$F
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]0
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Green]'Set Shutdown Mode (0=Shutdown, 1=Normal mode)
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]$C
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]0
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Green]'Blank all digits
[/color][color=Blue]for [/color][color=Black]temp [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]8
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Black]temp
Value [/color][color=DarkCyan]= [/color][color=Navy]15
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219
[/color][color=Blue]next
[/color][color=Green]'Enable Display (0=Shutdown, 1=Normal mode)
[/color][color=Black]Register [/color][color=DarkCyan]= [/color][color=Navy]$C
[/color][color=Black]Value [/color][color=DarkCyan]= [/color][color=Navy]1
[/color][color=Blue]gosub [/color][color=Black]SHIFT_TO_7219[/color]
Now, if I move the 'SHIFT_TO_7219' subroutine from the end of the .bas program file and place it at the end of the .basinc file (message length limitations prevent me from quoting the code again), then the MAX7219 initializes fine, does the brief all segments lit self test, but does NOT display the digits 1 through 8 ?? The displays remain blank...
The manual states that the #include directive is not yet implemented, but I've read on here that it actually is - and PE 6.0.8.1 has no issue with it.
I'm stumped as to why this doesn't work when the sub is in the .basinc file. If the #include imports code into the .bas file, then shouldn't the sub be there and work??
Stumped ??
Regards, John.