Dear All,
We currently use DZ60.
In several applications, we are interested to replace a NE555 in monostable mode by
a TPM timer of the DZ60. (On our application, when the 555 is triggered, its output generates a
pulse of a pre-defined time, polarity of trigger and output is not important).
I've looked at the TPM but I don't see how to create that with a TMP timer ?
If any one has created that function, I'm interested.
With a 18 MHz MCGCLK, accuracy would be 55 ns and max pulse with could be 3.6 ms
with is ok for us. (With the Renesas R8C we also use, it is possible but the timer is only 8 bits wide)
I've created a project which is a library, it compiles fine and creates a .lib file and a .lst file with the entries
but I've the following error : Can't read symbolics for targer crc.lib
I don't understand what could be wrong ?
In the .lib file, all the complete paths are indicated, is it possible to have only the short names ?
excuse me for my poor english level
with best regards
francois
Hello Francois,
On the timer issue, it should be possible to create an accurate monostable pulse using output compare mode for a TPM channel. The TPM module should remain free-running. Two pieces of code would be required - a function to initiate the pulse, and ISR code for the TPM channel. By using the TPM channel pin, the pulse width generated will not be affected by interrupt latency, except that there would be a minimum allowable pulse width setting determined by the worst case latency, including the potential effect of other non-related interrupts.
Perhaps something like the following untested code could be made to work - I assume the use of TPM2 channel 0 for the purpose of the example. The small delay mentioned needs to be sufficiently large for the function to exit prior to the first compare event occurring.
volatile word Pwidth; // Global variablevoid pulse_start( word width){ Pwidth = width; __asm sei; // Disable interrupts TPM2C0V = TPM2CNT + 50; // Add small delay to current count TPM2C0SC = 0x5C; // Pin is set on compare, // interrupt is enabled __asm cli; // Re-enable interrupts }interrupt void TPM2C0_ISR( void){ TPM2C0SC_CH0F = 0; // Clear flag TPM2C0V += Pwidth; // Add pulse width value TPM2C0SC = 0x18; // Pin is cleared on compare, // interrupt is disabled}
Regards,
Mac
Mac,
Thank you very much for your response.
Perharps it could be possible with another microcontroller in the HCS08 serie ?
I supposed it was possible by software but I would have prefer an automatic solution (hardware module of the microcontroller) (as a fault in only one pulse could make short circuit and destroy our device)
But I'll try and I'm confident with the software solution.
Have you an idea about the problem of library creation ?
Regards
francois
Hello Francois,
Here is a variation on the previously proposed method that does not require interrupt usage. Once the pulse is started, the pulse duration is determined entirely by the TPM peripheral hardware, with no further intervention by firmware.
void pulse_start( word width){ __asm sei; // Disable interrupts TPM2C0V = TPM2CNT + 20; // Add small delay to current count TPM2C0SC_CH0F = 0; // Clear flag TPM2C0SC = 0x1C; // Pin is set on compare while (!TPM2C0SC_CH0F); // Ensure flag becomes set TPM2C0V += width TPM2C0SC = 0x18; // Pin is cleared on compare __asm cli; // Re-enable interrupts}}
The "small delay" requires to be such that the first output compare event to set the output cannot occur prior to entry to the flag test loop.
Under what circumstances does a catastrophic failure occur - a missing pulse, pulse too short, or pulse too long? Is there a way to provide current limiting, of over-current protection?
I cannot help you with the library issue. There might be a better response if you were to post this topic alone to the Codewarrior forum.
Regards,
Mac