Hello,
I'm using TCC0 event input 0 to start the counter with TCC1 overflow event.
The behavior is good after chip programming, it is still ok after external reset but I loose the TCC0 triggering after a power off and restart.
After some investigations it seems that in TCC0 EVCTRL register, TCEI0 and EVACT0 are reseted after the power down and stay at 0 even if my program configure it during its initialisation.
The only way to recover the good behavior, is to program again the chip ...
TCC0 configuration fonction called in the main after system_init();
static void configure_tcc0(uint32_t width, uint32_t lag) { struct tcc_config config_tcc; struct tcc_events tcc_event_inst; tcc_get_config_defaults(&config_tcc, TCC0); //! [setup_change_config] config_tcc.counter.clock_source = GCLK_GENERATOR_4; config_tcc.counter.oneshot = true; config_tcc.counter.period = lag + (width/2) ; config_tcc.counter.direction = TCC_COUNT_DIRECTION_UP; config_tcc.compare.wave_generation = TCC_WAVE_GENERATION_DOUBLE_SLOPE_BOTH; //TCC_WAVE_GENERATION_SINGLE_SLOPE_PWM; config_tcc.compare.match[1] = lag; config_tcc.compare.wave_polarity[1] = TCC_WAVE_POLARITY_0; // inversé => commence à 0 puis passe a 1 //signal output config_tcc.pins.enable_wave_out_pin[1] = true; // enable wave out sur WO1 config_tcc.pins.wave_out_pin[1] = PIN_PA05E_TCC0_WO1; config_tcc.pins.wave_out_pin_mux[1] = PINMUX_PA05E_TCC0_WO1; // event 0 configuration tcc_event_inst.input_config[0].modify_action = true; // tres important sinon ne prend pas en compte les modif tcc_event_inst.input_config[0].action = TCC_EVENT0_ACTION_START; tcc_event_inst.on_input_event_perform_action[0] = true; tcc_init(&tcc0_instance, TCC0, &config_tcc); tcc_enable_events(&tcc0_instance,&tcc_event_inst); }
A cannot understand why the behavior is good after programming, even after external reset, and why it is definetly lost after power down.
if someone could help me ...
PS:
I'm testing the program on Feather M0
I use Microchip studio as IDE
I use ASF as framwork
my debugger is an Atmel-ICE