Hi flotulopex,
Check this http://www.picbasic.co.uk/forum/showthread.php?t=3753
May give you some ideas.
------------------
Hi flotulopex,
Check this http://www.picbasic.co.uk/forum/showthread.php?t=3753
May give you some ideas.
------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Thank you sayzer,
I found this thread already. I tried Melanie's way but it doesn't work.
First, it looks as "Digit" won't increment from 0 to 3.
Second, I have put a "spy" before entering the loop. I put PORTA.6 = 1.
Since I use PIC Simulator, I can see the port status and as soon as the program has started, PORTA.6 goes back to 0 (!?).
Am I doing something wrong?
In my code's FOR...NEXT loop, I have put:Code:for Digit = 0 to 3 value_d = value dig digit lookup value_d, [$7E,$0C,$B6,$9E,$CC,$DA,$FA,$0E,$FE,$DE], Segments PORTA.0(Digit) = ~DCD Digit PORTB = Segments next
Roger
I'm not so sure that ~DCD Digit will work. I could be wrong. Maybe: ~ (DCD Digit) ?
And I don't see an initial 'ENABLE' in the program itself...not sure if that's needed either or if interrupts are 'ENABLE'd by default.
Ha...just found the answer to that last 'not sure'. Page 183 of the PBP manual states that interrupts are NOT enabled by default...so, you have to turn them on.
Last edited by skimask; - 25th February 2007 at 20:10.
How about something simple, like:
HTH,Code:PORTA.0 = Digit.0 PORTA.1 = Digit.1 PORTA.2 = Digit.2 PORTA.3 = Digit.3
SteveB
I just made this piece of code as test.
It works except the PORTA.6 will change it's status from 1 to 0 when the firt loop will be executed.Code:MYPORT var PORTA Loop var BYTE PORTA.0 = MYport.0 PORTA.1 = MYport.1 PORTA.2 = MYport.2 PORTA.3 = MYport.3 PORTA.6 = 1 'Test to check port's state change in simulator... Start: for LOOP = 0 to 3 myport.0[Loop] = 1 'High myport.0[loop] = 0 'Low next goto start END
Last edited by flotulopex; - 25th February 2007 at 20:42.
Roger
I think you've got the variable declarations backwards.
Try myport.0 = porta.0, etc. instead of the way you have it.
this won't work indeed... and you make it too complicated for what it need to be.
MyPORT.0=PORTA.0 will work only once, If you want to alias a variable bit to a PORT bit... it's an all different story..Code:Start: for LOOP = 0 to 3 PORTA.0[Loop] = 1 'High PAUSE 500 PORTA.0[loop] = 0 'Low next goto start END
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I've attached two pictures about what I can see.
The first picture "Before Loop Start" shows that my PORTA.0 to 3 are set to "1". This is because I need them to be at this state before the main loop starts (driving CA Leds).
I did the same for PORTA.6 (=1) just for testing purpose. PORTA.6 will be used for something else in my program if I can handle the actual problem.
When I start the execution of the program, PORTA.6 goes to "0" witch is unwanted here.
Mister_E you're right, using DCD will modify all ports.... Was not a good idea on my side. Thank you for making me aware.
Roger
as you write to a BIT, it have to be 0 or 1 ONLY.Code:PORTA.0(Digit) = ~DCD Digit
Use a LCD or a serial comm to see the results of ~DCD digit... it return 254, 253, 251, 247.
i bet PORTA.0[Digit]=1 is what you're looking for.
Last edited by mister_e; - 25th February 2007 at 20:17.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks