I want to trigger a 100ns pulse on pin 57(EPWM 5A) whenever I get an external falling edge to interrupt on pin74. I need to know what to write in xint1_isr to trigger a 100ns pulse on pin 57.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I want to trigger a 100ns pulse on pin 57(EPWM 5A) whenever I get an external falling edge to interrupt on pin74. I need to know what to write in xint1_isr to trigger a 100ns pulse on pin 57.
Hi Anuj,
Do you only need the 100ns pulse to occur once? If so, I don't think EPWM functionality is required. What I would recommend is keeping pin 57 with GPIO functionality. You could setup a timer for 100ns, and within the xint1_isr start the timer/set the gpio high. Then, within the timer's isr (after the 100ns), set the gpio low and stop/reload the timer.
Best Regards,
Marlyn
It seems the best I can do using this method is a pulse of 1us but I need a shorter pulse. Any suggestions?
All I have inside the isr is this:
__interrupt void xint1_isr(void)
{
//
// Acknowledge interrupt group
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
CPUTimer_startTimer(CPUTIMER0_BASE);
GPIO_setPortPins(GPIO_PORT_A, GPIO_GPADIR_GPIO8);
}
//
// cpu_timer0_isr - CPU Timer0 ISR with interrupt counter
//
__interrupt void cpu_timer0_isr(void)
{
GPIO_clearPortPins(GPIO_PORT_A, GPIO_GPADIR_GPIO8);
CPUTimer_stopTimer(CPUTIMER0_BASE);
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
Still, there is a delay of 1us between the falling edge of the signal and the pulse, and the pulse instead of being 100ns is around 1us.
GPIO_setDirectionMode(23, GPIO_DIR_MODE_IN);
// XINT1 Synch to SYSCLKOUT only
GPIO_setQualificationMode(23, GPIO_QUAL_SYNC);
GPIO_setInterruptPin(23, GPIO_INT_XINT1);
GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_FALLING_EDGE);
GPIO_enableInterrupt(GPIO_INT_XINT1);
GPIO_setDirectionMode(8,GPIO_DIR_MODE_OUT);
Hi Anuj,
Can you please provide how you have configured the timer and what your clock settings are (what the source frequency is)?
Best Regards,
Marlyn
I was configuring the timer with 200MHz source frequency but now I am doing just the following:
//
// xint1_isr - xint 1 isr
//
__interrupt void xint1_isr(void)
{
//
// Acknowledge interrupt group
//
GPIO_setPortPins(GPIO_PORT_A, GPIO_GPADIR_GPIO8);
GPIO_clearPortPins(GPIO_PORT_A, GPIO_GPADIR_GPIO8);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
Even with setting and clearing GPIO pin in subsequent lines removing the overhead of starting the CPU timer, the pulse width is ~200ns so now I am thinking that's the best f28379s control card can do.
Anuj,
I recommend taking a look at this thread, another alternative you could do is inserting the proper delay between the set and clear instructions (note that you will need to account for the time it takes to clear and set the gpio as described in the following thread: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/594791/ccs-tms320f28377s-delay-function-for-tms320f28377s
Best Regards,
Marlyn
I was using the same command between set and clear instructions asm(" RPT #20 || NOP"), for a 200MHz clk, 20 cycles should give me 100ns, but it was giving roughly 500ns, so i just removed it. I am open to suggestions which can do it quickly. Also, if you can recommend me something which would reduce the time lag between the falling edge of input and gpio getting high. I moved this part of the code in CPU2 which is just handling xint1_isr and the lag is still 400ns.
Hello Anuj,
Is your program running on RAM or on FLASH? FLASH tends to run slower, but otherwise there should not be an issue.
Omer Amir
Hi Anuj,
If you are still getting issues with the speed, the only other thing I can recommend is to create the pulse in assembly code, since the driverlib functions inherently have some delay because of the way the code is compiled (there are more instructions than it seems).
Best regards,
Omer Amir