Hello All;
I am using TMS320F2812 for developing embedded application. My application has ECana1 interface communicating with remote system. I would like to schedule transmission of CAN message every 130 us. I am using Timer0 for scheduling CAN message transmission.
When i transmit CAN message without Timer0 (in Timer0 ISR), message is transmitted successfully on CAN bus, CAN Transmit Acknowledge flag (TA2) is set.
But, when i schedule my CAN message transmission with Timer0 (in Timer0 ISR), message is not transmitted on CAN bus, CAN Transmit Acknowledge flag (TA2) is not set.
I have set breakpoints in ECana1 ISR --> case 2 in application software under both conditions mentioned above (With Timer0 and Without Timer0). When Timer0 is not used for scheduling CAN message transmission, program halts at breakpoint, but when Timer0 is used for scheduling CAN message transmission, program does not halts at breakpoint.
What could be the reason for the program not halting at breakpoint when Timer0 is used for CAN message scheduling ?
Please suggest solutions to this problem.
Thank you,
Sunil Sawant
I have pasted my program code below:
/*---------------------- Application Main.c - Start ------------------------*/
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"
/* Global Variable Declarations */
struct ECAN_REGS ECanaShadow;
struct ECAN_REGS ECanbShadow;
//struct ECAN_MBOXES ECanaReadData;
t__TMS320F2812ECanaTransactionDataObject tTMS320F2812ECanaTransactionDataObject;
t__TMS320F2812ECanaTransactionStatusFlags tTMS320F2812ECanaTransactionStatusFlags;
t__TMS320F2812ECanaMailboxReceiveObject tTMS320F2812ECanaMailboxReceiveObject;
t__TMS320F2812ECanaMailboxTransmitObject tTMS320F2812ECanaMailboxTransmitObject;
t__TMS320F2812ECanaMessageObject tTMS320F2812ECanaMessageObject;
//Uint32 u32TransmitMDH = 0x08070605;
//Uint32 u32TransmitMDL = 0x04030201;
Uint32 u32TransmitMDH = 0x02010F0E;
Uint32 u32TransmitMDL = 0x0D0C0B0A;
Uint32 mdh = 0;
Uint32 mdl = 0;
void main(void)
{
/* Step 1. Initialize System Control: */
/* PLL, WatchDog, enable Peripheral Clocks */
/* This example function is found in the DSP2833x_SysCtrl.c file. */
InitSysCtrl();
/* Step 2. Configure MCU pins to be used by eCANA */
//InitECanGpio();
/* Step 3. Initialize the eCAN module */
InitECan();
/* Step 4. Initialize the CPU Timers */
InitCpuTimers();
/* Step 5. Configure CPU Timers */
/* 100MHz CPU Freq, 1 second Period (in uSeconds) */
ConfigCpuTimer(&CpuTimer0, 150, 130);
/* Step 6. Initialize the PIE vector table with pointers to the shell Interrupt */
/* Service Routines (ISR). */
/* This will populate the entire table, even if the interrupt */
/* is not used in this example. This is useful for debug purposes. */
/* The shell ISR routines are found in DSP2833x_DefaultIsr.c. */
/* This function is found in DSP2833x_PieVect.c. */
InitPieVectTable();
/* Step 7. Clear all interrupts and initialize PIE vector table. */
/* Disable CPU interrupts and clear all CPU interrupt flags. */
DINT;
IER = 0x0000;
IFR = 0x0000;
/* Step 8. Initialize the PIE control registers to their default state. */
/* The default state is all PIE interrupts disabled and flags */
/* are cleared. */
/* This function is found in the DSP2833x_PieCtrl.c file. */
InitPieCtrl();
/* Step 9. Disable interrupts again (for now) */
DINT;
/* Step 10. Interrupts that are used in this example are re-mapped to */
/* ISR functions found within this file. */
EnableInterrupts();
/* Step 11. Initialize Mailbox Queues */
//vInitializeMailboxQueues();
/* Step 12. Now eCANA is ready to transmit/receive message on CAN bus */
//vTransmitECanaMessage(&u32TransmitMDH, &u32TransmitMDL);
vStartCpuTimer(&CpuTimer0);
while(1)
{
asm(" NOP");
asm(" NOP");
asm(" NOP");
//vTransmitECanaMessage(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
//vTransmitECanaMailbox1Message(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
//vTransmitECanaMailbox2Message(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
///vTransmitECanaMailbox3Message(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
//vTransmitECanaMailbox4Message(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
//vTransmitECanaMailbox5Message(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
//vCommandTransmittingControlParameters();
if(tTMS320F2812ECanaTransactionStatusFlags.Mailbox2.bit.b1CmdTxgCtrlParMsgTxd == 1)
{
//vStopCpuTimer(&CpuTimer0);
tTMS320F2812ECanaTransactionStatusFlags.Mailbox2.bit.b1CmdTxgCtrlParMsgTxd = 0;
vTransmitECanaMailbox2Message(&u32TransmitMDH, &u32TransmitMDL);
asm(" NOP");
}
asm(" NOP");
asm(" NOP");
asm(" NOP");
}
}
/*---------------------- Application Main.c - End -------------------------*/
*---------------------- DSP28xx_PieCtrl.c - Start -------------------------*/
void EnableInterrupts(void)
{
/*
// Enable the PIE
PieCtrlRegs.PIECRTL.bit.ENPIE = 1;
// Enables PIE to drive a pulse into the CPU
PieCtrlRegs.PIEACK.all = 0xFFFF;
// Enable Interrupts at the CPU level
EINT;
*/
/* ---------- eCANA Peripheral Mailboxes Enable - Start ----------- */
/* Enable the PIE */
PieCtrlRegs.PIECRTL.bit.ENPIE = 1;
/* Enables PIE to drive a pulse into the CPU */
PieCtrlRegs.PIEACK.all = 0xFFFF;
/* Configure CAN interrupts */
ECanaShadow.CANMIL.all = ECanaRegs.CANMIL.all;
ECanaShadow.CANMIL.all = 0xFFFFFFFF; // Interrupts asserted on eCAN0INT and eCAN1INT
ECanaRegs.CANMIL.all = ECanaShadow.CANMIL.all;
/* Disable register-write protection, since CANGIM and CANMIM registers are EALLOW protected */
EALLOW;
ECanaShadow.CANMIM.all = ECanaRegs.CANMIM.all;
//ECanaShadow.CANMIM.all = 0x00000006; // Enable interrupts for mailboxes 1 and 2
ECanaShadow.CANMIM.all = 0xFFFFFFFF; // Enable interrupts for all mailboxes
ECanaRegs.CANMIM.all = ECanaShadow.CANMIM.all;
ECanaShadow.CANGIM.all = ECanaRegs.CANGIM.all;
ECanaShadow.CANGIM.all = 0;
ECanaShadow.CANGIM.bit.AAIM = 1; // Enable Abort Interrupt
ECanaShadow.CANGIM.bit.WDIM = 1; // Enable Watchdog Timer Interrupt
ECanaShadow.CANGIM.bit.WUIM = 1; // Enable
ECanaShadow.CANGIM.bit.BOIM = 1; // Enable
ECanaShadow.CANGIM.bit.EPIM = 1; // Enable
ECanaShadow.CANGIM.bit.WLIM = 1; // Enable
ECanaShadow.CANGIM.bit.I0EN = 1; // Enable eCAN1INT or eCAN0INT
ECanaShadow.CANGIM.bit.I1EN = 1;
ECanaRegs.CANGIM.all = ECanaShadow.CANGIM.all;
/* ---------- eCANA Peripheral Mailboxes Enable - End ------------ */
/* ---------- eCANA Peripheral ISR Assignment - Start ----------- */
/* Reassign ISRs. i.e. reassign the PIE vector for ECAN0INTA_ISR and ECAN0INTA_ISR
to point to a different ISR than the shell routine found in DSP28_DefaultIsr.c.
This is done if the user does not want to use the shell ISR routine but instead
wants to embed the ISR in this file itself. */
PieVectTable.ECAN0INTA = &ECAN0INTA_ISR;
PieVectTable.ECAN1INTA = &ECAN1INTA_ISR;
/* ---------- eCANA Peripheral ISR Assignment - End ------------- */
/* ---------- CPU Timer0 Peripheral Interrupt Lines - Start ---------- */
PieVectTable.TINT0 = &TINT0_ISR;
/* ---------- CPU Timer0 Peripheral Interrupt Lines - End ------------ */
/* Enable register-write protection */
EDIS;
/* ---------- eCANA Peripheral Interrupt Lines - Start ---------- */
/* Configure PIE interrupts */
//PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable vector fetching from PIE block
PieCtrlRegs.PIECRTL.bit.ENPIE = 1;
PieCtrlRegs.PIEACK.bit.ACK9 = 1; // Enables PIE to drive a pulse into the CPU
// The interrupt can be asserted in either of the eCAN interrupt lines
// Comment out the unwanted line...
PieCtrlRegs.PIEIER9.bit.INTx5 = 0; // Enable INTx.5 of INT9 (eCAN0INT)
PieCtrlRegs.PIEIER9.bit.INTx6 = 1; // Enable INTx.6 of INT9 (eCAN1INT)
/* Configure system interrupts */
IER |= 0x0100; // Enable INT9 of CPU
/* ---------- eCANA Peripheral Interrupt Lines - End ------------ */
/* ---------- Timer0 Peripheral Interrupt Lines - Start ---------- */
/* Enable CPU INT1 which is connected to CPU TIMER0 INT: */
//IER |= M_INT10; //M_INT1;
PieCtrlRegs.PIECRTL.bit.ENPIE = 1;
PieCtrlRegs.PIEACK.bit.ACK10 = 1;
/* Enable Timer0 INTn in the PIE: Group 3 interrupt 1-6 */
//PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER10.bit.INTx7 = 1;
IER |= M_INT10; //M_INT1; // Enable INT10 of CPU
/* ---------- Timer0 Peripheral Interrupt Lines - End ------------ */
/* Enable Interrupts at the CPU level */
EINT;
/* Enable Global realtime interrupt DBGM */
ERTM;
}
*---------------------- DSP28xx_PieCtrl.c - End -------------------------*/
/*---------------------- DSP28xx_DefaultISR.c - Start -------------------------*/
interrupt void ECAN1INTA_ISR(void) // eCAN-A
{
// Insert ISR Code here
switch(ECanaRegs.CANGIF1.bit.MIV1)
{
case 2 : // Mailbox 2 - Command Transmitting Control Parameters
ECanaShadow.CANTA.all = 0;
ECanaShadow.CANTA.bit.TA2 = 1;
ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
asm(" NOP");
/* ECanaShadow.CANRMP.all = 0; // Clear RMP2 interrupt on eCAN1
ECanaShadow.CANRMP.bit.RMP2 = 1;
ECanaRegs.CANRMP.all = ECanaShadow.CANRMP.all;
*/ break;
case default :
break;
}
/*---------------------- DSP28xx_DefaultISR.c - End -------------------------*/
*---------------------- DSP28xx_DefaultISR.c - Start -------------------------*/
interrupt void TINT0_ISR(void) // CPU-Timer 0
{
// Insert ISR Code here
tTMS320F2812ECanaTransactionStatusFlags.Mailbox2.bit.b1CmdTxgCtrlParMsgTxd = 1;
asm(" NOP");
// To receive more interrupts from this PIE group, acknowledge this interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//asm (" ESTOP0");
//for(;;);
}
*---------------------- DSP28xx_DefaultISR.c - End --------------------------*/