set flags within a variable?


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default set flags within a variable?

    Hello Everyone. I have a word variable with a number that begins at 0 and slowly advances to 1199. It then resets to 0 and the cycle repeats. What I want to do is set flags at certain points to toggel a port high. For example, if flags are set at variable 11 and variable 126, as the variable advances and reaches 11, portb.1 goes high. Now it goes low until variable 126 is reached and goes high again, etc. Does anyone have an idea to accomplish this? Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    "...reaches 11, portb.1 goes high. Now it goes low until variable 126 is reached and goes high.."

    Could you be more specific at Value=11 ?

    How long to make it high then low again?


    ------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    May be you need something like:

    if my_var=11 then portb.1=1
    if my_var=129 then portb.1=0

    Ioannis

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Select case?

    or maybe you want something running in background? if so, set a timer interrupt the do the Select Case and PORTB=x in the ISR.

    That's usually how i handle my pushbuttons...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Thanks for the replies guys. I've gone a little further, simplified things and had success. The variable 0 - 1199 is the address lines in an ISD5008 voice record chip. I've programmed it to record and count the individual messages recorded. When played back, it performs a message cue and plays back only the number of messages recorded and returns the address to 0. So if you record 5 messages it will only playback those 5 messages. While you are recording, if portb.0 = 1, it sets the flag to make PORTC.6 high during playback on that particular message. I put a gosub to write MESSAGESRECORDED into eeprom. Upon playback it reads the eeprom locations and IF MESSAGESRECORDED = MESSAGESPLAYED THEN HIGH PORT.6. So if I flag message 5, upon playback if it reads a 5 during playback of message 5 it will go high. I have 59 unused eeprom locations in my 16F872 so I can flag up to 59 messages to make PORTC.6 high. After playing the message it then returns to START and makes PORTC.6 low again. I just read my original post and apologize for being so vague.

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    peterdeco1,

    If it is not too much to request, could you pls post the schematic and the working code?

    -----------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  3. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

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