Correct syntax please ?


Closed Thread
Results 1 to 2 of 2
  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Correct syntax please ?

    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:

    Code:
    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

    Code:
    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

    Code:
    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

    Code:
    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

  2. #2
    Early1's Avatar
    Early1 Guest


    Did you find this post helpful? Yes | No

    Default

    The syntaxx is

    High portb[i]

    what you know is easy.

Similar Threads

  1. Is this simple schematic electrically correct?
    By sccoupe in forum Schematics
    Replies: 4
    Last Post: - 12th November 2009, 16:41
  2. Replies: 0
    Last Post: - 1st September 2008, 07:03
  3. Math operations & Syntax?
    By kevj in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 23rd February 2008, 01:40
  4. Serial LCD syntax help
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 27th February 2007, 04:37
  5. Syntax error PIC16F684
    By milestag in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st September 2005, 18:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts