http://www.picbasic.co.uk/forum/showthread.php?t=561
And it would REALLY help to know which PIC you are using...
http://www.picbasic.co.uk/forum/showthread.php?t=561
And it would REALLY help to know which PIC you are using...
Re-read that linked post above...read it good, read it carefully...then re-read the 3rd paragraph...then re-read it again...
And if you're not sure if it's a TOGGLE failure or not, then don't use TOGGLE...
Surely you can come up with a different method of changing the state of a bit from one to the other and back again...
...when I add ADCON1 = 7 to the code after trisA and trisB it does not change the outcome. Here is the code:
DEFINE OSC 48
'
test1 var PORTA.1
test2 var PORTA.2
trisA = 0
trisB = 0
ADCON1 = 7
ProgramStart:
pause 5
toggle test1 '// comment -- THIS DOES NOT WORK!
toggle test2 '// these two lines AND
if portB = 0 then
portB = $ff
'//toggle test1 '// uncomment -- THIS WORKS
else
portB = 0
'//toggle test2 '// uncomment
endif
goto ProgramStart
Depending where toggle is it either work or does not work. If you have the possibility to test this, please let me know if works on your pic.
Thank you in advance
Regards
Key
1/2 way there...keep reading and re-reading...
And again...read the PBP manual about TOGGLE. Not that TOGGLE is a bad command, but there are other ways to flip a bit...
Anybody got the link to the R-M-W 'writeup' thread here?
The PIC is running 48Mhz here (apparently). I see possible R-M-W issues...
Besides that...look at your code...There are logical flow flaws (is that the correct way to put that?) in it...
How do you know TOGGLE isn't actually working the way it should?
Can you see that fast? I can't...
Last edited by Pic_User; - 15th October 2008 at 00:16. Reason: Fix quote
Ohm it's not just a good idea... it's the LAW !
Thank you Skimask, you are right, I'm 1/2 way there and in fact even slightly further... I did read a little bit further also...
Found in the pic18F4550 data sheet that LATA is about the same as PORTA, so I changed PORTA.1 to LATA.1 and that solved the issue. However I do not understand why PORTA does not work and LATA works in this "example". Could somebody try to explain that shortly, I am sure it will help ohter people also. Knowing that LATx is included in the 18F pics, but still does not grasp how it (change toggle place) works like it does?
How could this be an r-m-w matter?
Regards
Key
Read-Modify-Write, it's briefly explained in the PBP manual somewhere...and it's also explained in those links above a bit...
Bookmarks