Hi all,
I am using a TMS320F28075 controller and trying to communicate to an external flash device over SPI. Everything works correctly until I enable a 20 Khz interrupt "appTask", code below. The code inside this interrupt is critical and so I cant disable it or make it smaller.
With this 20 Khz interrupt enabled, not all the data is written to or read correctly from the external flash. Only small chunks of data are successfully written/read and the amount is random.
It looks like the interrupt is interfering with SPI comms. I would have thought the SPI's peripherals are external and would work independently of the main thread or interrupts.
Is it possible to have the below interrupt enabled and have the SPI communication working correctly? Or am I doing something wrong?
Any help would be greatly appreciated.
// -------------------------- interrupt code -------------------------------------------------- /* Set the interrupt vector */ EALLOW; { PieVectTable.TIMER0_INT = &appTask; } EDIS; /* Configure CPU-Timer 0: */ ConfigCpuTimer( &CpuTimer0, ( SYSCLK / 1000000 ), MAINTENANCE_PERIOD_uS ); CpuTimer0Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0 /* Enable CPU int1 which is connected to CPU-Timer 0 */ IER |= M_INT1; /* Enable TINT0 in the PIE: Group 1 interrupt 7 */ PieCtrlRegs.PIEIER1.bit.INTx7 = 1; /* Enable global Interrupts and higher priority real-time debug events: */ EINT; ERTM; // -------------------------- interrupt code -------------------------------------------------- // ------------------------- SPI port init ----------------------------------------------------- /* Control Register (SPICCR).... 'normal' values * Clock polarity normal * Loopback off * SPI Character length (see SPRUHM9B Table 17-9) 0xF => 16-bits * SPI High Speed mode disabled (not allowed with selected GPIO - see SPRUHM9B section 17.2.2) */ SPI_PORT.SPICCR.bit.CLKPOLARITY = 1; SPI_PORT.SPICCR.bit.SPILBK = 0; SPI_PORT.SPICCR.bit.SPICHAR = 0x0F; SPI_PORT.SPICCR.bit.HS_MODE = 0; //sww12jan16 /* SPI Operation Control Register (SPICTL).... * Disable rx overrun interrupt * Clock phase normal * Master mode * Transmit enabled * Enable SPI interrupt */ SPI_PORT.SPICTL.bit.OVERRUNINTENA = 0; SPI_PORT.SPICTL.bit.CLK_PHASE = 1; SPI_PORT.SPICTL.bit.MASTER_SLAVE = 1; SPI_PORT.SPICTL.bit.TALK = 1; SPI_PORT.SPICTL.bit.SPIINTENA = 1; /* SPI Status Register (SPISTS).... 'normal' values * Clear any outstanding flags */ SPI_PORT.SPISTS.all = 0; /* SPI Baud Rate Register (SPIBRR) * max baud rate must be less than the max gpio toggle frequency = 25MHz (See SPRUHM9B section 17.3.5 and SPRS902B section 5.7.6.1) * and less than the slowest device - TC77 max frequency = 7MHz (could select different rates for different devices) * For SPIBRR > 2, SPI Baud Rate LSPCLK/(SPIBRR+1), where LSPCLK = SYSCLK/4 = 30Mhz * For SPIBRR = 0, 1, or 2, baud = LSPCLK/4 = 7.5MHz */ SPI_PORT.SPIBRR.bit.SPI_BIT_RATE = 4; /* 30/(4+1) = 6MHz jan16 */ /* SPI FIFO Transmit Register (SPIFFTX) * 0xE0 => fifo enable; enhancements enable; tx enable * 0x63 => clear outstanding INT; interrupt on FiFo <=3 * !!DAVEC!! set FiFo for best latency at 5MHz */ /* Reset all to default */ SPI_PORT.SPIFFTX.all = 0; SPI_PORT.SPIFFTX.all = 0xE063; /* SPI FIFO Receive Register (SPIFFRX) * 0x60 => clear overflow; rx enable; * 0x61 => clear outstanding INT; interrupt on FiFo >= 1 */ /* Reset all to default */ SPI_PORT.SPIFFRX.all = 0; SPI_PORT.SPIFFRX.all = 0x6061; SPI_PORT.SPICCR.bit.SPILBK = 0; /* SPI FIFO Control Register (SPIFFCT) * Delay between FiFo and transmit Shift Reg. */ SPI_PORT.SPIFFCT.bit.TXDLY = 0x00; /* SPI Priority Control Register (SPIPRI) * Free-run on emulation suspend * SPISTE non-inverted (not used here anyway) * Normal 4-wire SPI mode */ SPI_PORT.SPIPRI.bit.FREE = 1; SPI_PORT.SPIPRI.bit.STEINV = 0; SPI_PORT.SPIPRI.bit.TRIWIRE = 0; // --------------------------------------------------------------Thanks for your time.