Thanks Paul, I didn t know that link.
I thought that reading from an Interrupt routine should not be a problem, since register for writing and reading different are.
Here my code:
Code:
// This ISR routine triggers when an event occurs. This could happen the channel CH0
// changes level.
if( FTM0_C0SC & 0x80 ) {
// If on channel CH0 is raising edge (TTL = 1)
if( ( GPIOC_PDIR & 0b0000000000000010 ) ) {
// ...dann reset counter to zero
FTM0_CNT = 0x00;
} else {
// ...otherwise check if there is a failing edge on the line and now TTL = 0
// in this case read the timer for CH0
if( ( ( GPIOC_PDIR & 0b0000000000000010 ) ^ 0b0000000000000010 ) ) {
// read and convert the result in microseconds
tempRegister = ( FTM0_C0V * 1000000 ) / 15625;
// and then check if received datas are in the right interval
if( ( tempRegister > MIN_PULSE_RX ) && (tempRegister < MAX_PULSE_RX ) ) {
// ...when in the right spektrum save data in the struct
dataServo.throttlePulse = tempRegister;
}
}
}
// clear channel interrupt flag (CHF) before exiting
FTM0_C0SC &= ~( 0x80 );
}
Using uint32_t as a "container" for the register works without problems!
Thanks