I am not using registers, the pins being set here are just for testing with simulator.
I have a main program with a "command" that calls the Sub(include file) with Parameters, the 3rd Param is the state of the bit 0 or 1. The bit being set is in an array.
& I had another issue that was masking somewhat the main problem...
Anyway I have it working,, in main code I didn't have In SEG_on as Bit & the sub was reading a byte?
The test code here still doesn't work but I will put that aside. (too tired to think now)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am not having trouble passing the variable from the sub back to main. The code below is a modified version of the original code. Modified to DIM some undeclared variables and added a 2nd Tmp Variable.
Both LEDS toggle as expected. This shows that the variables are being returned to the Main routine.
Sorry, my bad. somehow a typo got inserted in my testing & main was calling with SEG_on.
The following is the original sub I was having trouble with, declaring SEG_on as bit got it working. The other issue was I was calling another sub (now deleted) & I had the params reversed.
In this sub I set TMtmp_1.Seg_n = SEG_on
[I really need to get more sleep...]
tmSegBuf(DIGn, SEGn, BitState)SubtmSegBuf(InDig_n, InSeg_n, InSEG_onasbit, OptionalInDbuf()=DispBuf)IfSeg_n=0thenExitSubSeg_n--' Seg 1 = bit0 of array byteTMtmp_1=DBuf(Dig_n)TMtmp_1.Seg_n=SEG_onDBuf(Dig_N)=TMtmp_1EndSub
How do I pass a bit var to a subroutine ?
I thought I had it working but I had a typo & was just referencing the source variable from the main. (reproduced in following code)
Capturing port pins on logic analyzer...
I have the same issue if I pass a bit value.
Last edit: ToniG 2022-06-27
Use a Macro to pass a register.bit value.
I am not using registers, the pins being set here are just for testing with simulator.
I have a main program with a "command" that calls the Sub(include file) with Parameters, the 3rd Param is the state of the bit 0 or 1. The bit being set is in an array.
& I had another issue that was masking somewhat the main problem...
Anyway I have it working,, in main code I didn't have In SEG_on as Bit & the sub was reading a byte?
The test code here still doesn't work but I will put that aside. (too tired to think now)
When I meant register.bit value that means port.bit value, register.bit value or variable.bit value.
As in
This may help: https://github.com/GreatCowBASIC/Help/wiki/setwith
I am not having trouble passing the variable from the sub back to main. The code below is a modified version of the original code. Modified to DIM some undeclared variables and added a 2nd Tmp Variable.
Both LEDS toggle as expected. This shows that the variables are being returned to the Main routine.
I am using GCB Build 1132 with an 18F25K22
Last edit: William Roth 2022-06-27
A problem is that I don't think the following is supported
For Example:
This will not turn on PortC.3
It should do.
Missing a DIR PORTC OUT ?
Which chip?
This seems to work here.
Sorry, my bad. somehow a typo got inserted in my testing & main was calling with SEG_on.
The following is the original sub I was having trouble with, declaring
SEG_on as bit
got it working. The other issue was I was calling another sub (now deleted) & I had the params reversed.In this sub I set
TMtmp_1.Seg_n = SEG_on
[I really need to get more sleep...]
So all is good now ?
Yes, this is resolved - thanks all.
Just the wee issue with toggling a Var bit with Not
https://sourceforge.net/p/gcbasic/discussion/596084/thread/9a9ce1752a/