??? 05/10/04 14:35 Read: times |
#70125 - RE: branching ports through memory mapping Responding to: ???'s previous message |
Thanks Russell, but may be i should put what i really want to do so that my objective becomes clear but i hope its not a big story.
I want to design a program which uses the concept of state machine & do the following; 1) P2.0 & P2.1 are used as input, waiting for low signal. 2) When ever low comes on any of the bits, controller will sents 8 bits data from P1 to a device. 3) if now low comes on the next bit also, controller will sent separate 8 bit data to the same device. 4) If there occur no change on the bit after showing low i.e. the input bit keep on showing low for 5 seconds then controller will again sent new data to the same device through P1 port. (there are two patterns of data for each bit) 5) So controller should work out the timing and input low or high for both P2.1 and P2.0 separately i.e. each bit is treated individually, separate counters (for 5 seconds)for both bits and both counters should act separately depending upon the logic state of input bits p2.0 or p2.1. (i.e. if the bit keeps on showing low the counter keeps on counting till 5 seconds but if bits show high during 5 seconds counter reset and controller take back the bit at the first state) Considering the above, iam planning to write the code using the following idea & i need suggestions from you people to work out this effectively considering that later more states and input bits will be added but for now lets consider only two bits so that things become clear for a new learner like me; Main program: (SCAN LIST) the main program has a scan list in which controller mointor both bits to see if a low comes. If Low comes controller remove that particular bit from the Scan List and move it to State_1 but at the same time checks the remaining bit in the check list. Total STATES of a input bit; 1) STATE_1 making sure that there is low on input bit 2) STATE_2 sending 8 bits data through P1 to a device 3) STATE_3 Starting the 5 sec. counter for that bit, also checking if this bit is still showing low now here comes two conditions; a) if bit shows low upto 5 seconds, send new 8 bits data from P1 and taking this bit back to scan list. b) if bit shows High witin 5 seconds, then also take it back to scan list Now the thing that i don;t understand even after reading the code from the following link,which has every thing that i need, is that how to make use of timers and counters setting up memory places and how to manage these thing through coding. Specially should my code check each state of each bit after a certain period of time or should it check all the bits for low first? and where to keep the main timer like 1.25msec intrepput should this be in the main loop and scanning should be in the ISR, next should there be two lookup tables one for scanning the bit status and the other for sending the type of 8 bit data from P1? http://www.8052.com/users/mkaras/State_Machine.A51 --------------------- |
Topic | Author | Date |
branching ports through memory mapping | 01/01/70 00:00 | |
RE: branching ports through memory mapping | 01/01/70 00:00 | |
RE: branching ports through memory mapping | 01/01/70 00:00 | |
RE: branching ports through memory mapping | 01/01/70 00:00 | |
Simplifying | 01/01/70 00:00 | |
RE: branching ports through memory mapping | 01/01/70 00:00 | |
Plz close this thread![]() | 01/01/70 00:00 |