> -----Messaggio originale----- > Da: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]Per conto di Mike Keitz > Inviato: giovedl 31 dicembre 1998 20.29 > A: PICLIST@MITVMA.MIT.EDU > Oggetto: Re: compact sort program > > > On Thu, 31 Dec 1998 18:08:30 +0100 Gianni writes: > >Hi! > >I have written a program for a PIC16F84 that emulate a motorized 2 cam > >programmable daily timer. > >I keep in PIC's eeprom the setpoint (20 max) in the following > >24h BCD format 1)byte HH 2)byte mm 3)byte which bit I want to > >set/reset . > >Every minute I compare the actual time with the setpoint and if time > >is >= > >setpoint I copy the third byte in a buffer then repaet for next > >setpoint. > > >At the end of eeprom , I copy the buffer to the out port . > >This works properly only if setpoint (HH:mm) are in ascending order. > > It seems like it would work no matter what the order is, if you check all > the setpoints every minute. The only conflict would be if two or more > setpoints are telling the same output to go opposite ways the same > minute. In that case, the last one in the table would dominate. > Suppose it's 12:10 and I have in eeprom the following setpoints : SET time mode comparison result 05:30 ON ON (if actual time>=SET the n 08:00 OFF OFF buffer=mode 11:15 ON ON else 19:00 OFF Skip end if ) and the buffer at the exit of routine is correct. Now I add a setpoint in the eeprom after the the last one 03:18 ON ON 05:00 OFF OFF and the buffer has a wrong result ; the last win. To get correct result I must keep the table in order or make a different kind of comparison ? > >Unfortunately I have only 27 bytes of code free and 25 of ram. > > If I were writing this (in assembler), I can't imagine the time-keeping > and setpoint-checking parts of the program needing more than 100 or so > code locations. The rest of the space could be used by the likely much > more complicated code to provide a user interface to set the setpoints. In fact all the code is used for handling LCD display, IIC real-time clock,two button input device,and some text string for the menu. > It may be time to review the situation and re-write your program > entirely. Most of my projects go through at least one such total > rewrite. > > ___________________________________________________________________ > You don't need to buy Internet access to use free Internet e-mail. > Get completely free e-mail from Juno at http://www.juno.com/getjuno.html > or call Juno at (800) 654-JUNO [654-5866] >