Hello,
I am using Teensy 3.6 with the latest versions of Arduino IDE and Teensyduino on windows. I am trying to trigger the ADC with a center-alligned PWM with an interrupt following the application notes AN4410 and AN5142 from NXP. However, the IDE does not recognize NVICIP58, NVICICPR1 and NVICISER1 or any NVIC for that matter.
The code below:
Does anyone have a solution for this?
Thanks in advance
I am using Teensy 3.6 with the latest versions of Arduino IDE and Teensyduino on windows. I am trying to trigger the ADC with a center-alligned PWM with an interrupt following the application notes AN4410 and AN5142 from NXP. However, the IDE does not recognize NVICIP58, NVICICPR1 and NVICISER1 or any NVIC for that matter.
The code below:
Code:
void initFTM1() {
FTM1_SC = 0x00; //disables the FTM1 counter
FTM1_CONF = 0xC0; //set up BDM in 11
FTM1_FMS = 0x00; //clear the WPEN so that WPDIS is set in FTM1_MODE register
FTM1_MODE |= 0x05; //enable writing on the FTM CnV registers
FTM1_SC = 0x28; //CPWM is enabled, driving from system clock divided by 1
FTM1_C0SC = 0x28; //High_Low_high for center-alignment
FTM1_C1SC = 0x28;
FTM1_COMBINE = 0x12; //complementary mode for CH0&CH1 and deadtime insertion
FTM0_DEADTIME = 0x00;
FTM1_CNT = 0x00; //FTM1 counter register
FTM1_CNTIN = 0x00; //initial counter value, better to start at 0
FTM1_MOD = 500;
asm("nop");
FTM1_EXTTRIG |= 0x10; //FTM1_C0V triggers the ADC
}
void initADC() {
SIM_SCGC3 |= 0x08000000; //enable ADC1 clock
PORTC_PCR7 = 0x100; //PTC7 in GPIO mode
GPIOC_PDDR = 0x80; //PTC direction register, PTC7 is in output mode
ADC1_CFG1 = 0x44; //ADCCLK/2 and single-ended 12-bit conversion
ADC1_CFG2 = 0x4; //enable high-speed conversion
ADC1_SC2 = 0x40; //enable hardware trigger
ADC1_SC3 = 0x00; //not continuous conversion
ADC1_SC1A = 0x54; //enable ADC interrupt, single-ended, and select A20
SIM_SOPT7 = 0x8900; //FTM1 trigger ADC1, alternative triggering
asm("cpsie i"); //interrupt enable
NVICIP58 = 0x30; //setting interrupt priority of ADC1
NVICICPR1 |= 1<<26; //clear the pending register of interrupt source 58
NVICISER1 |= 1<<26; //set the interrupt source of ADC1
ADC_ISR();
}
void ADC_ISR(void) {
GPIOC_PTOR = 0x80; //toggle indicator
sample[0] = ADC1_RA;
asm("nop");
}
Does anyone have a solution for this?
Thanks in advance