Нужно сделать захват таймера по изменнию состояния входа (PF4).
Текст программы:
Код
#include "avr_compiler.h"
#include "port_driver.h"
#include "event_system_driver.h"
void main(void)
{
/* Configure PF4 as input, sense on both edges. */
PORTF.PIN4CTRL |= PORT_ISC_BOTHEDGES_gc;
PORTF.DIRCLR = 0x10;
/* Select PF4 as event channel 0 multiplexer input. */
EVSYS_SetEventSource( 0, EVSYS_CHMUX_PORTF_PIN4_gc );
/* Select event channel 0 as event source for TCC0 and input
* capture as event action.
*/
TCC0.CTRLD = (uint8_t) TC_EVSEL_CH0_gc | TC_EVACT_CAPT_gc;
/* Enable TCC0 "Compare or Capture" Channel A. */
TCC0.CTRLB |= TC0_CCAEN_bm;
/* Configure TCC0 with the desired frequency and period. */
TCC0.PER = 0xFFFF;
TCC0.CTRLA = TC_CLKSEL_DIV1_gc;
while (1) {
if ( TCC0.INTFLAGS & TC0_CCAIF_bm ) {
/* Clear interrupt flag when new value is captured.
* The last capture value is now available
* in the CCA register.
*/
TCC0.INTFLAGS |= TC0_CCAIF_bm;
}
}
}
При изменении уровня на входе PF4 захвата не происходит.
CPU: ATxmega256A3.
Используется таймер TCC0.
Что неправильно?