Dear all,
Here is a challenge.
How would you go about generating a fixed number of pulses in the background with picaxe, if you are not allowed to use settimer count? On top of that, both, HPWM and PWM are already used for other functions. Solutions can include external hardware. Preferably tiny .
To elaborate:
1)hardware is 40x2;
2)pulses should be more or less a square wave with period of approx. 500us and there would be between 1 and 200 such pulses to issue;
3)in the background means only issuing the pulses should take me away from the main program and worst case - stopping (i.e. interrupt);
4)settimer count is already busy counting elsewhere, thus it cannot be used (it could be used by feeding some pin back to it to count pulses);
5)hpwm is used in half-bridge mode, i.e. outputs C and D are used; pwm output (C.1) is used to adjust brightness of a LED array;
The purpose is driving a stepper motor driver IC with STEP and DIR inputs with less attention from the main program. Clearly, using a separate picaxe is a solution, but this being the only reason for a separate chip, it becomes expensive in many ways (the least of which is the cost of the chip itself).
Basically there are three non-blocking ways of generating a square wave that come to mind - PWM, SR Latch and HSPI2 (HI2C1 occupied). PWM is kind of used up. SR Latch is tempting, but the fundamental issue remains - how to stop it when the required number of pulses have been issued? HSPI2 output could be interesting - if consecutive 10101010 bytes would be sent on data output and clock set to double the frequency required, this could work, but requires hacking the second MSSP module. Not trivial, but has been documented. On top of that, forming the actual spi command might turn out not to be very fast.
I have been looking for integrated devices, but there is only one I have found and it is huge (by my standards) - PCA9629. I have looked for some sort of serial counter that I could send a number 154 and it would pulse a pin on its own for 154 times, but I'm no good with 74xx and 40xx devices, so it is very well possible I have missed something.
Brainstorm, please .
Thank you for your inputs,
Edmunds
Here is a challenge.
How would you go about generating a fixed number of pulses in the background with picaxe, if you are not allowed to use settimer count? On top of that, both, HPWM and PWM are already used for other functions. Solutions can include external hardware. Preferably tiny .
To elaborate:
1)hardware is 40x2;
2)pulses should be more or less a square wave with period of approx. 500us and there would be between 1 and 200 such pulses to issue;
3)in the background means only issuing the pulses should take me away from the main program and worst case - stopping (i.e. interrupt);
4)settimer count is already busy counting elsewhere, thus it cannot be used (it could be used by feeding some pin back to it to count pulses);
5)hpwm is used in half-bridge mode, i.e. outputs C and D are used; pwm output (C.1) is used to adjust brightness of a LED array;
The purpose is driving a stepper motor driver IC with STEP and DIR inputs with less attention from the main program. Clearly, using a separate picaxe is a solution, but this being the only reason for a separate chip, it becomes expensive in many ways (the least of which is the cost of the chip itself).
Basically there are three non-blocking ways of generating a square wave that come to mind - PWM, SR Latch and HSPI2 (HI2C1 occupied). PWM is kind of used up. SR Latch is tempting, but the fundamental issue remains - how to stop it when the required number of pulses have been issued? HSPI2 output could be interesting - if consecutive 10101010 bytes would be sent on data output and clock set to double the frequency required, this could work, but requires hacking the second MSSP module. Not trivial, but has been documented. On top of that, forming the actual spi command might turn out not to be very fast.
I have been looking for integrated devices, but there is only one I have found and it is huge (by my standards) - PCA9629. I have looked for some sort of serial counter that I could send a number 154 and it would pulse a pin on its own for 154 times, but I'm no good with 74xx and 40xx devices, so it is very well possible I have missed something.
Brainstorm, please .
Thank you for your inputs,
Edmunds