What happens if X=1 ?
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Sorry - I made a silly mistake in the code I posted. The case where X=1 shows my error.
However, the real code that was/is causing trouble was for a larger range of X and included '>=', '<='.
My poor attempt to simplify the real problem failed!
I'll tidy up the real code and post it soonest.
Thanks for your input.
Regards Bill legge
Sorry for my earlier muddled post. I've done some more work on the problem and have pinned down my difficulty.
I am compiling using PBPL and using a graphic LCD with 4 driver chips.
The GLCD is 240 pixels wide and I need to activate the Chip Selects as the display sweeps along:
0 to 63 CS1
64 to 127 CS2
128 to 191 CS3
192 to 239 CS4
The chip selects are connected to PORTB and my code is:
If I compile using PBP it works properly and the chip selects turn on/off as X goes from 0 to 239.Code:clear DEFINE OSC 40 ' Run on PIC18F8722, HSPPL ADCON1 = $0F ' Set PortA to digital TRISB=0 ' Make Port B outputs PORTB=0 ' clear the port X var byte Loop: PORTB=$0 for X = 0 to 239 if X<64 then PORTB=$01 if X>63 and X<128 then PORTB=$02 if X>127 and X<192 then PORTB=$04 if X>191 then PORTB=$08 pause 5 next X goto Loop
If I compile using PBPL it does not work.
I need to use the LONG compilation. Any idea what is going wrong?
Regards Bill Legge
Hi Bill,
No idea what's wrong at this point.
But I did run your program as is, no changes, on an 18F252.
Works the same with either PBPW or PBPL.
You can also do the same thing like this ...Added:Code:for X = 0 to 239 PORTB = DCD (X >> 6) pause 5 next X
So that it only affects those 4 pins, you could do this ...Code:PORTB = (PORTB & $F0) | DCD (X >> 6)
Last edited by Darrel Taylor; - 11th July 2009 at 04:12. Reason: Added:
DT
Silly question.
PM or MPASM ?
Or does it matter?
Dave
Always wear safety glasses while programming.
I'm using MPASM because the PBP does not support the PIC18F8722
Regards Bill Legge
I am new with PICBASIC
I am trying to understand
Good luck for all.
Last edited by kindows; - 11th July 2009 at 06:38.
Bookmarks