Part Number:OMAP-L138
Tool/software: Starterware
Dear All,
I would like to initialize AFE5809 EVM using SPI module of OMAP L138 LCDK. In order to initiate the AFE5809 EVM, I need to generate the following three signals (SEN, SCLK, and SDATA) using the SPI module of our OMAP L138 LCDK.
I am using the SPI example of the Starterware (Ver. 1_10_04_01). I can successfully see the SDATA and SCLK. However, I cannot generate the SEN signal. My professor suggested that the issue could be with the configuration of the SPI module. So, I have attached my code bellow. Please check why I cannot generate SEN signal. Thank you so much
Code:
/****************************************************************************** ** INTERNAL MACRO DEFINITIONS *******************************************************************************/ /* value to configure SMIO,SOMI,CLK and CS pin as functional pin */ #define SIMO_SOMI_CLK_CS 0x00000E01 // use: 0x00000E01 or 0x00000E03 or 0x00000E05 or 0x00000E07 ?? #define CHAR_LENGTH 0x8 #define sajad_SPI_DATA_FORMAT SPI_DATA_FORMAT0 /****************************************************************************** ** INTERNAL FUNCTION PROTOTYPES *******************************************************************************/ static void SPIConfigDataFmtReg(unsigned int dataFormat); void SPIIsr(void); /****************************************************************************** ** INTERNAL VARIABLE DEFINITIONS *******************************************************************************/ volatile unsigned int flag = 1; unsigned int tx_len; unsigned int rx_len; unsigned char vrf_data[260]; unsigned char tx_data[260]; volatile unsigned char rx_data[260]; unsigned char *p_tx; volatile unsigned char *p_rx; /****************************************************************************** ** INTERNAL FUNCTION DEFINITIONS *******************************************************************************/ int main(void) { /* Waking up the SPI1 instance. */ PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_SPI1, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); SPIPinMuxSetup(1); /* ** Using the Chip Select(CS) 0 pin of SPI1 to communicate with the Fingerprint Sensor. */ SPI1CSPinMuxSetup(0); // default 4 ?? /* #################### Enable use of SPI1 interrupts START ####################### */ // Setup the ARM or DSP interrupt controller #ifdef _TMS320C6X // Initialize the DSP interrupt controller IntDSPINTCInit(); // Register the ISR in the vector table IntRegister(C674X_MASK_INT4, SPIIsr); // Map system interrupt to the DSP maskable interrupt IntEventMap(C674X_MASK_INT4, SYS_INT_SPI1_INT); // Enable the DSP maskable interrupt IntEnable(C674X_MASK_INT4); // Enable DSP interrupts globally IntGlobalEnable(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Register the ISR in the Interrupt Vector Table.*/ IntRegister(SYS_INT_SPINT1, SPIIsr); /* Set the channnel number 2 of AINTC for system interrupt 56. * Channel 2 is mapped to IRQ interrupt of ARM9. */ IntChannelSet(SYS_INT_SPINT1, 2); /* Enable the System Interrupts for AINTC.*/ IntSystemEnable(SYS_INT_SPINT1); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); #endif /* #################### Enable use of SPI1 interrupts END ####################### */ /* ################### Configuring and enabling the SPI1 instance START ######################## */ unsigned char cs = 0x01; // unsigned char dcs = 0x01; // unsigned int val = SIMO_SOMI_CLK_CS; SPIReset(SOC_SPI_1_REGS); SPIOutOfReset(SOC_SPI_1_REGS); SPIModeConfigure(SOC_SPI_1_REGS, SPI_MASTER_MODE); //SPIClkConfigure(SOC_SPI_1_REGS, 150000000, 20000000, SPI_DATA_FORMAT0); SPIClkConfigure(SOC_SPI_1_REGS, 150000000, 1000000, sajad_SPI_DATA_FORMAT); SPIPinControl(SOC_SPI_1_REGS, 0, 0, &val); SPIDefaultCSSet(SOC_SPI_1_REGS, dcs); /* Configures SPI Data Format Register */ SPIConfigDataFmtReg(sajad_SPI_DATA_FORMAT); /* Selects the SPI Data format register to used and Sets CSHOLD * to assert CS pin(line) */ SPIDat1Config(SOC_SPI_1_REGS, (SPI_CSHOLD | sajad_SPI_DATA_FORMAT), cs); /* map interrupts to interrupt line INT1 */ SPIIntLevelSet(SOC_SPI_1_REGS, SPI_RECV_INTLVL | SPI_TRANSMIT_INTLVL); /* Enable SPI communication */ SPIEnable(SOC_SPI_1_REGS); /* ################### Configuring and enabling the SPI1 instance END ######################## */ while(1){ // printf("\n initiate AFE5809 using SPI start "); // part 1 tx_data[0] = 0x16; tx_data[1] = 0x01; tx_data[2] = 0x16; tx_data[3] = 0x01; tx_data[4] = 0x16; tx_data[5] = 0x01; tx_data[6] = 0x00; tx_len = 7; rx_len = 7; /* asserts the CS pin(line) */ SPIDat1Config(SOC_SPI_1_REGS, (SPI_CSHOLD | sajad_SPI_DATA_FORMAT), cs); p_tx = &tx_data[0]; p_rx = &rx_data[0]; SPIIntEnable(SOC_SPI_1_REGS, (SPI_RECV_INT | SPI_TRANSMIT_INT)); while (flag) ; flag = 1; /* Deasserts the CS pin(line) */ SPIDat1Config(SOC_SPI_1_REGS, sajad_SPI_DATA_FORMAT, cs); } } /* ** Configures Data Format register of SPI ** */ static void SPIConfigDataFmtReg(unsigned int dataFormat) { /* Configures the polarity and phase of SPI clock */ // SPIConfigClkFormat(SOC_SPI_1_REGS, (SPI_CLK_POL_HIGH | SPI_CLK_INPHASE), dataFormat); SPIConfigClkFormat(SOC_SPI_1_REGS, (SPI_CLK_POL_LOW | SPI_CLK_INPHASE), dataFormat); /* Configures SPI to transmit MSB bit First during data transfer */ SPIShiftMsbFirst(SOC_SPI_1_REGS, dataFormat); /* Sets the Charcter length */ SPICharLengthSet(SOC_SPI_1_REGS, CHAR_LENGTH, dataFormat); } /* ** Enables SPI Transmit and Receive interrupt. ** Deasserts Chip Select line. */ /* ** Data transmission and receiption SPIIsr ** */ void SPIIsr(void) { unsigned int intCode = 0; #ifdef _TMS320C6X IntEventClear(SYS_INT_SPI1_INT); #else IntSystemStatusClear(56); #endif intCode = SPIInterruptVectorGet(SOC_SPI_1_REGS); while (intCode) { if (intCode == SPI_TX_BUF_EMPTY) { tx_len--; SPITransmitData1(SOC_SPI_1_REGS, *p_tx); p_tx++; if (!tx_len) { SPIIntDisable(SOC_SPI_1_REGS, SPI_TRANSMIT_INT); } } if (intCode == SPI_RECV_FULL) { rx_len--; *p_rx = (char) SPIDataReceive(SOC_SPI_1_REGS); p_rx++; if (!rx_len) { flag = 0; SPIIntDisable(SOC_SPI_1_REGS, SPI_RECV_INT); } } intCode = SPIInterruptVectorGet(SOC_SPI_1_REGS); } } /******************************* End of file *********************************/