在移植框架以与 Tiva C 配合使用后、我将重复使用来自 NXP 微控制器的单位测试
我的问题是、在我将 PWM 设置为触发器后、我似乎无法通过占空比控制触发器。 我只能通过改变 PWM 频率来减少触发器的数量。
触发器是与 PWM 信号的时钟相关联还是配置问题?
我有一个在每次触发时调用的 fucnion:
void UT_ANALOG_SEQUENCE_Hook(ANALOG_SEQUENCE_t* sequence, ANALOG_t* analog, void* data) { // gUT_ANALOG_SEQUENCE_acc += ANALOG_Read( analog ); int32_t temp; ADCSequenceDataGet(ANALOG_SEQUENCE_GetAdcBase(sequence), ANALOG_SEQUENCE_GetSequencerNumber(sequence), &temp); gUT_ANALOG_SEQUENCE_acc += temp; gUT_ANALOG_SEQUENCE_counter++; }
我的代码会根据已使用的序列发生器以及我们希望序列发生器运行的最大通道数自动定义序列发生器。 由于该单位测试仅需要1个通道、因此它将序列发生器3定义为所选的通道。
按照以下步骤启用序列发生器:
ADCSequenceDisable(); ADCSequenceConfigure(); // here I just use the sequencer number as a priority // because we don't actually need proper priorities set up ADCSequenceStepConfigure(); // as many as we need for the channels we want // being the last added channel the one that will // carry ADC_CTL_IE | ADC_CTL_END | channel ADCIntRegister(); // this one registers the proper irq handler based // on adc [0..1] and sequencer [0..3] PWMGenIntTrigEnable() // here I set up the trigger for pwm based on // a previous pwm created, using PWM_TR_CNT_ZERO // (I'm a begginer in embedded engineering, I don't // know how to use all the other flags that are // possible here, nor what do they mean... // I'd love a quick reference to something // as I can't find a detailed description on these hahaha) ADCIntEnable(); IntEnable(); ADCSequenceEnable();
是否缺少我跳过的步骤? 还是仅根据 PWM 的时钟触发?