Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 15th February 2007, 04:19 PM   (permalink)
Default question on PIC16F84 CODE ???

Hi everyone ...

actually I am stuck now with my assembly code for PIC16F84 ... basically I am writing a code for controlling 6 LEDs and they work as the following sequence :

00001100 for 10 seconds and 00100001 for 10 seconds as well and repeat this process and my circuit has been designed to be interrupted by a switch connected say on A0 Pin ... what I want now is how can I write just the interrupt Service Routine code to make these LEDs after pressing the switch to jump to the next sequence .. for example if my sequence (1) is 00001100 and after 5 seconds from this sequence, the interruption occured so the PIC must jump straight away to seq(2) which is 00100001 and stay on this sequence for 20 seconds and then return the normal process which is sequence(1) for 10s and seq(2) for 10s. However I have to write my code with just the assembly not in any other language !!!!
yak103 is offline  
Old 15th February 2007, 04:22 PM   (permalink)
Default

You might try checking my tutorials for some ideas?, there doesn't seem any reason for interrupts in your program though?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 15th February 2007, 04:31 PM   (permalink)
Default

look my friends, what I want is just how can the sequence jump to the other sequence for X seconds when the switch is pressed and then the normal process carry over !!!

this is my question and I have read alot of books and could not find anything relates to this problem !!! plz help me
yak103 is offline  
Old 15th February 2007, 04:38 PM   (permalink)
Default

Think of a loop run a certain number of times to give the ten second timing, and jumping out of the loop when a key is pressed to another loop.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 15th February 2007, 06:38 PM   (permalink)
Default

Quote:
Originally Posted by yak103
.. for example if my sequence (1) is 00001100 and after 5 seconds from this sequence, the interruption occured so the PIC must jump straight away to seq(2) which is 00100001 and stay on this sequence for 20 seconds
Not making much sense.

Why 20 seconds, not 10 or 15 seconds?

Is it always 20 seconds?
__________________
L.Chung
eblc1388 is offline  
Old 15th February 2007, 06:53 PM   (permalink)
Default

this is just an example of the timming system in my code ... in my code it will be maybe 5 or 6 or ...... it is just an example of what i want !!
yak103 is offline  
Old 15th February 2007, 10:30 PM   (permalink)
Default

As you want to use interrupts rather than just poll an input, you can use an input on portB as a means to trigger it, see application note AN566:
http://ww1.microchip.com/downloads/e...tes/00566b.pdf

Within the interrupt, you then would have to determine which sequence is currently enabled, either by directly reading the port register or a flag bit that you set to indicate the state of the sequences.
Then toggle to the other sequence, set the time delay counter for 20 seconds and exit the interrupt.
It sounds easy - but you are guaranteed to have problems unless you are already experienced in using interrupts, you will need to study the interrupt section in the manual.
You must also incorporate code to de-bounce the pushbutton so that it can not repeatedly trigger the interupt and therefore toggle the sequence more than once per operation.
picasm is offline  
Old 16th February 2007, 03:07 AM   (permalink)
Default

With running counters is the answer.

seq 1
seq 2 ----->Forced interrupt - advance to 3 --> return to 2
seq 3
seq 4 ----->Forced interrupt - advance to 5 --> return to 4
seq 5

At any time button pressed:
* Set FORCED flag
* Set seq time shorter
* Advance seq #

In all seq routines:
* Import seq time
* Check for Forced flag, if it is set then reset seq # just before seq is complete and clear the Forced flag.
OR
* Check for Forced flag in a global seq # monitor/advancer.


What is your definition of "normal process carry over"? Does this mean after returning from a forced sequence the seq # automatically resets to #1 or more so to return back to the prior seq # before the interruption? All you need to do is keep track of the running seq # with a variable. So whenever an interruption occurs, do it and aftwards, return back to the running seq #.
donniedj is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
16F88 Code protected question RonnyBone Micro Controllers 6 30th October 2006 09:30 AM
AT89C4051 assembly code compiler question fiveten Micro Controllers 5 26th March 2006 07:37 PM
Tough assembly program for the PIC16F84 asmpic Micro Controllers 34 3rd December 2004 07:50 PM
Hey Nigel, LCD code question.... NewGeek Micro Controllers 5 3rd September 2004 05:37 PM
An error in pic16f84a, why? Zener_Diode Micro Controllers 6 11th April 2004 03:55 AM



All times are GMT. The time now is 07:20 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker