??? 11/22/06 21:40 Read: times |
#128426 - Moving in the positive Responding to: ???'s previous message |
Mohammed,
Ok, we're moving ahead here! The code layout and comments makes things a lot easier! MOV PULSES,#250 ; PULSES DESIRED MOV A,PULSES MOV B,#02H ; PCA TIMESOUT EVERY 500us ( HOWEVER two 500uS timeouts makes 1 pulse ) MUL AB *********************************************** MOV .LOW(PULSES),A MOV .HIGH(PULSES),B ; Now Pulse Counter Holds correct pulses needed What are you trying to achieve here??? ************************************************** You multiply the value in PULSES by two then store the result in the low and high address of PULSES? From my interptretation, A (with a value of 250 * 2 = 0F4h) would get stored into PULSES and B (whose value is 01h) will get stored into memory location 0, which is R0. Not quite what you want to achive methinks. Remember - the ramp will be exponential - 100 pulses at 1khz,100 pulses at 2khz etc, so the acceleration will increase. If you want a constant acceleration, you will need to compute the number of pulses per frequency range - is: 100 pulses at 1khz,200 pulses at 2khz etc. One possible solution for this is to use another table for the number of pulses and make PULSES a 16 bit variable. Erik - I don't think there is too much code in the ISR. The OP has told us what cpu -P89C51RD2HBA at 25MHz if my memory serves me correct. Execution time I don't think is an issue at this point - remember get it working properly then optimise! |