PDA

View Full Version : set flags within a variable?



peterdeco1
- 20th October 2006, 10:46
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.

sayzer
- 20th October 2006, 11:03
"...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?


------------

Ioannis
- 20th October 2006, 12:58
May be you need something like:

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

Ioannis

mister_e
- 20th October 2006, 13:07
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...

peterdeco1
- 24th October 2006, 10:49
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.

sayzer
- 24th October 2006, 11:07
peterdeco1,

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

-----------------------