PDA

View Full Version : Correct syntax please ?



malc-c
- 10th June 2006, 23:57
Hi again,

Flushed with my success in pulsing an LED via PWM on a 16F628a and then failing to port it to a 12F675 (all because of a simple ; to rem out a line in the inc file.. thanks guys !) I went back to the 16F628 and thought about taking the basic flash a LED program a stage further and get 8 leds on port B to chase one after the other. I've already set varibles for "i" and set the ports up etc, so I'll just deal with what I've tried, and hopefully you'll see my logic ;)

I've tried running these in a loop:



i = 0
high PORTB.i
pause 500
low PORTB.i
pause 500
if i = 7 then i = 0


That falls over at the second line "PORTB.i" I've tried it as a FOR NEXT loop changing the "i = 0" for "FOR i = 0 to 7"

Thinking it was the syntax that was the problem I've tried



High PORTB.(i)
High PORTB.[i]
PORTB.i = 1
PORTB.(i)=1


They all halt the compile. So I thought that the problem might be that you can't use a varible directly with the PORT statement so I created a bit varibles LED1, LED2 etc and tried



High LED(i)
High LED[i]
LED(i)=1
Etc


Ok I thought, lets look at it another way. How about sending a value of varible i directly to the port. So I set up i to double each time in a loop



i = 1
PORTB=%i
PAUSE 500
i = i + i
if i = 128 then i = 1



That too errors (Bad token %).

So I'm stummped. Any ideas on how to simply get the LEDs on PORT B to chase other than PORTB.0 = 1, delay, PORTB.0 =0, delay, PORTB.1 =1 etc


Sorry for the duplicate post - I received a message stating a problem with the forums, and a message has been sent to the admin team, and I should try refreshing - I did and the second time it reset - obviously sending my post twice ! - Mods, please feel free to delete one of the threads to tidy it up

Early1
- 11th June 2006, 09:09
The syntaxx is

High portb[i]

what you know is easy.