enorton1379
Member
Hi All,
I am finally getting somewhere with the Teensy 4.1 board and Visual Micro software. I kinda hit a road block and need a little guidance. I used the GPT timer with interrupt in MCUXpresso like so and need something similar for Visual Micro project:
// Init
const gpt_config_t GPT1_config = {
.clockSource = kGPT_ClockSource_Periph,
.divider = 1UL,
.enableFreeRun = false,
.enableRunInWait = false,
.enableRunInStop = false,
.enableRunInDoze = false,
.enableRunInDbg = false,
.enableMode = true
};
static void GPT1_init(void) {
/* GPT device and channels initialization */
GPT_Init(GPT1_PERIPHERAL, &GPT1_config);
GPT_SetOscClockDivider(GPT1_PERIPHERAL, 1);
GPT_SetOutputCompareValue(GPT1_PERIPHERAL, kGPT_OutputCompare_Channel1, 255);
GPT_SetOutputOperationMode(GPT1_PERIPHERAL, kGPT_OutputCompare_Channel1, kGPT_OutputOperation_Disconnected);
/* Enable GPT interrupt sources */
GPT_EnableInterrupts(GPT1_PERIPHERAL, kGPT_OutputCompare1InterruptEnable);
/* Interrupt vector GPT1_IRQn priority settings in the NVIC. */
NVIC_SetPriority(GPT1_GPT_IRQN, GPT1_GPT_IRQ_PRIORITY);
/* Enable interrupt GPT1_IRQn request in the NVIC. */
EnableIRQ(GPT1_GPT_IRQN);
/* Start the GPT timer */
GPT_StartTimer(GPT1_PERIPHERAL);
}
// Enable Interrupt
GPT_EnableInterrupts(GPT1_PERIPHERAL, kGPT_OutputCompare1InterruptEnable);
// Disable Interrupt
GPT_DisableInterrupts(GPT1_PERIPHERAL, kGPT_OutputCompare1InterruptEnable);
void GPT1_GPT_IRQHANDLER(void)
{
/* Clear interrupt flag.*/
GPT_ClearStatusFlags(GPT1_PERIPHERAL, kGPT_OutputCompare1Flag);
.........
}
// Change the compare value
GPT_SetOutputCompareValue(GPT1_PERIPHERAL, kGPT_OutputCompare_Channel1, val_Comp);
Question is can I use this same code in Visual Micro and if so how or is there another way to do exactly the same thing? Please let me know.
Thanks,
Eric Norton
I am finally getting somewhere with the Teensy 4.1 board and Visual Micro software. I kinda hit a road block and need a little guidance. I used the GPT timer with interrupt in MCUXpresso like so and need something similar for Visual Micro project:
// Init
const gpt_config_t GPT1_config = {
.clockSource = kGPT_ClockSource_Periph,
.divider = 1UL,
.enableFreeRun = false,
.enableRunInWait = false,
.enableRunInStop = false,
.enableRunInDoze = false,
.enableRunInDbg = false,
.enableMode = true
};
static void GPT1_init(void) {
/* GPT device and channels initialization */
GPT_Init(GPT1_PERIPHERAL, &GPT1_config);
GPT_SetOscClockDivider(GPT1_PERIPHERAL, 1);
GPT_SetOutputCompareValue(GPT1_PERIPHERAL, kGPT_OutputCompare_Channel1, 255);
GPT_SetOutputOperationMode(GPT1_PERIPHERAL, kGPT_OutputCompare_Channel1, kGPT_OutputOperation_Disconnected);
/* Enable GPT interrupt sources */
GPT_EnableInterrupts(GPT1_PERIPHERAL, kGPT_OutputCompare1InterruptEnable);
/* Interrupt vector GPT1_IRQn priority settings in the NVIC. */
NVIC_SetPriority(GPT1_GPT_IRQN, GPT1_GPT_IRQ_PRIORITY);
/* Enable interrupt GPT1_IRQn request in the NVIC. */
EnableIRQ(GPT1_GPT_IRQN);
/* Start the GPT timer */
GPT_StartTimer(GPT1_PERIPHERAL);
}
// Enable Interrupt
GPT_EnableInterrupts(GPT1_PERIPHERAL, kGPT_OutputCompare1InterruptEnable);
// Disable Interrupt
GPT_DisableInterrupts(GPT1_PERIPHERAL, kGPT_OutputCompare1InterruptEnable);
void GPT1_GPT_IRQHANDLER(void)
{
/* Clear interrupt flag.*/
GPT_ClearStatusFlags(GPT1_PERIPHERAL, kGPT_OutputCompare1Flag);
.........
}
// Change the compare value
GPT_SetOutputCompareValue(GPT1_PERIPHERAL, kGPT_OutputCompare_Channel1, val_Comp);
Question is can I use this same code in Visual Micro and if so how or is there another way to do exactly the same thing? Please let me know.
Thanks,
Eric Norton