Part Number: PROCESSOR-SDK-AM335X
I started to implement SPI für SPI1 and used SPI0 Flash Example as a base, but I can't get it working. I seems that I even don't receive any data. I enabled all Clocks and configured the Pinmux for all need Pins. I want to recieve data only. The SPI receive register "MCSPI_RX0" is always zero and interrupt is never triggered. In the following you can see my code. Am I missing anything?
Update1: After removing the line where I activated the RX FIFO I now have the correct data in MCSPI_RX0 register, but the my receive interrupt is not triggered. Now I try using the FIFO register.
Update2: Interrupt is now triggered in none fifo mode. I missed enabling master interrupt (IntMasterIRQEnable).
#define PINMODE3 3
McSPI1ModuleClkConfig();
McSPIReset(MCSPISLV_MCSPI_REGS);
MCSPISysConfigSetup(MCSPISLV_MCSPI_REGS, MCSPI_CLOCKS_OCP_ON_FUNC_ON,
MCSPI_SIDLEMODE_NO, MCSPI_WAKEUP_DISABLE,
MCSPI_AUTOIDLE_OFF);
McSPICSEnable(MCSPISLV_MCSPI_REGS);
McSPISlaveModeEnable(MCSPISLV_MCSPI_REGS);
MCSPIPinDirSet(SOC_SPI_1_REGS, MCSPI_RX_ONLY_MODE, MCSPI_DATA_LINE_COMM_MODE_7, 0);
MCSPIMultiChModeEnable(SOC_SPI_1_REGS);
McSPIClkConfig(SOC_SPI_1_REGS, MCSPI_IN_CLK, MCSPI_OUT_FREQ,
MCSPI_CH_NUM, MCSPI_CLK_MODE_0);
McSPIWordLengthSet(MCSPISLV_MCSPI_REGS, MCSPI_WORD_LENGTH(8), MCSPI_CH_ZERO);
McSPICSPolarityConfig(MCSPISLV_MCSPI_REGS, MCSPI_CS_POL_LOW, MCSPI_CH_ZERO);
McSPIIntEnable(MCSPISLV_MCSPI_REGS, MCSPI_INT_RX_FULL(MCSPI_CH_ZERO));
McSPIRxFIFOConfig(MCSPISLV_MCSPI_REGS, MCSPI_RX_FIFO_ENABLE, MCSPI_CH_ZERO);
/* Initializing the ARM Interrupt Controller. */
IntAINTCInit();
/* Registering interrupt. */
IntRegister(SYS_INT_SPI1INT, SPIReceiveIsr);
/* Setting the priority for interrupt in AINTC. */
IntPrioritySet(SYS_INT_SPI1INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
/* Enabling the interrupt in AINTC. */
IntSystemEnable(SYS_INT_SPI1INT);
McSPIChannelEnable(MCSPISLV_MCSPI_REGS, MCSPI_CH_ZERO);
McSPIReceiveData(MCSPISLV_MCSPI_REGS, MCSPI_CH_ZERO);
}
int McSPI1PinMuxSetup()
{
HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI1_SCLK) = CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_PUTYPESEL | CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_RXACTIVE | PINMODE3;
HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI1_D0) = CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_PUTYPESEL | CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_RXACTIVE | PINMODE3;
HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI1_D1) = CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_PUTYPESEL | CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_RXACTIVE | PINMODE3;
HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI1_CS0) = CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_PUTYPESEL | CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_RXACTIVE | PINMODE3;
}
void McSPI1ModuleClkConfig(void)
{
HWREG(SOC_CM_PER_REGS + CM_PER_L3S_CLKSTCTRL) =
CM_PER_L3S_CLKSTCTRL_CLKTRCTRL_SW_WKUP;
while((HWREG(SOC_CM_PER_REGS + CM_PER_L3S_CLKSTCTRL) &
CM_PER_L3S_CLKSTCTRL_CLKTRCTRL) != CM_PER_L3S_CLKSTCTRL_CLKTRCTRL_SW_WKUP);
HWREG(SOC_CM_PER_REGS + CM_PER_L3_CLKSTCTRL) =
CM_PER_L3_CLKSTCTRL_CLKTRCTRL_SW_WKUP;
while((HWREG(SOC_CM_PER_REGS + CM_PER_L3_CLKSTCTRL) &
CM_PER_L3_CLKSTCTRL_CLKTRCTRL) != CM_PER_L3_CLKSTCTRL_CLKTRCTRL_SW_WKUP);
HWREG(SOC_CM_PER_REGS + CM_PER_L3_INSTR_CLKCTRL) =
CM_PER_L3_INSTR_CLKCTRL_MODULEMODE_ENABLE;
while((HWREG(SOC_CM_PER_REGS + CM_PER_L3_INSTR_CLKCTRL) &
CM_PER_L3_INSTR_CLKCTRL_MODULEMODE) !=
CM_PER_L3_INSTR_CLKCTRL_MODULEMODE_ENABLE);
HWREG(SOC_CM_PER_REGS + CM_PER_L3_CLKCTRL) =
CM_PER_L3_CLKCTRL_MODULEMODE_ENABLE;
while((HWREG(SOC_CM_PER_REGS + CM_PER_L3_CLKCTRL) &
CM_PER_L3_CLKCTRL_MODULEMODE) != CM_PER_L3_CLKCTRL_MODULEMODE_ENABLE);
HWREG(SOC_CM_PER_REGS + CM_PER_OCPWP_L3_CLKSTCTRL) =
CM_PER_OCPWP_L3_CLKSTCTRL_CLKTRCTRL_SW_WKUP;
while((HWREG(SOC_CM_PER_REGS + CM_PER_OCPWP_L3_CLKSTCTRL) &
CM_PER_OCPWP_L3_CLKSTCTRL_CLKTRCTRL) !=
CM_PER_OCPWP_L3_CLKSTCTRL_CLKTRCTRL_SW_WKUP);
HWREG(SOC_CM_PER_REGS + CM_PER_L4LS_CLKSTCTRL) =
CM_PER_L4LS_CLKSTCTRL_CLKTRCTRL_SW_WKUP;
while((HWREG(SOC_CM_PER_REGS + CM_PER_L4LS_CLKSTCTRL) &
CM_PER_L4LS_CLKSTCTRL_CLKTRCTRL) !=
CM_PER_L4LS_CLKSTCTRL_CLKTRCTRL_SW_WKUP);
HWREG(SOC_CM_PER_REGS + CM_PER_L4LS_CLKCTRL) =
CM_PER_L4LS_CLKCTRL_MODULEMODE_ENABLE;
while((HWREG(SOC_CM_PER_REGS + CM_PER_L4LS_CLKCTRL) &
CM_PER_L4LS_CLKCTRL_MODULEMODE) != CM_PER_L4LS_CLKCTRL_MODULEMODE_ENABLE);
HWREG(SOC_CM_PER_REGS + CM_PER_SPI1_CLKCTRL) &= ~CM_PER_SPI1_CLKCTRL_MODULEMODE;
HWREG(SOC_CM_PER_REGS + CM_PER_SPI1_CLKCTRL) |=
CM_PER_SPI1_CLKCTRL_MODULEMODE_ENABLE;
while((HWREG(SOC_CM_PER_REGS + CM_PER_SPI1_CLKCTRL) &
CM_PER_SPI1_CLKCTRL_MODULEMODE) != CM_PER_SPI1_CLKCTRL_MODULEMODE_ENABLE);
while(!(HWREG(SOC_CM_PER_REGS + CM_PER_L3S_CLKSTCTRL) &
CM_PER_L3S_CLKSTCTRL_CLKACTIVITY_L3S_GCLK));
while(!(HWREG(SOC_CM_PER_REGS + CM_PER_L3_CLKSTCTRL) &
CM_PER_L3_CLKSTCTRL_CLKACTIVITY_L3_GCLK));
while(!(HWREG(SOC_CM_PER_REGS + CM_PER_OCPWP_L3_CLKSTCTRL) &
(CM_PER_OCPWP_L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L3_GCLK |
CM_PER_OCPWP_L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L4_GCLK)));
while(!(HWREG(SOC_CM_PER_REGS + CM_PER_L4LS_CLKSTCTRL) &
(CM_PER_L4LS_CLKSTCTRL_CLKACTIVITY_L4LS_GCLK |
CM_PER_L4LS_CLKSTCTRL_CLKACTIVITY_SPI_GCLK)));
}
Resulting Registers:
McSPI1 McSPI1 Registers
MCSPI_REVISION 0x40300A0B The McSPI system configuration register (MCSPI_REVISION) allows control of various parameters of the module interface. It is not sensitive to software reset. [Memory Mapped]
MCSPI_SYSCONFIG 0x00000308 The McSPI system configuration register (MCSPI_SYSCONFIG) allows control of various parameters of the module interface. It is not sensitive to software reset. [Memory Mapped]
MCSPI_SYSSTATUS 0x00000001 The McSPI system status register (MCSPI_SYSSTATUS) provides status information about the module excluding the interrupt status information. [Memory Mapped]
MCSPI_IRQSTATUS 0x00010001 The McSPI interrupt status register (MCSPI_IRQSTATUS) regroups all the status of the module internal events that can generate an interrupt. [Memory Mapped]
MCSPI_IRQENABLE 0x00000004 This McSPI interrupt enable register (MCSPI_IRQENABLE) enables/disables the module internal sources of interrupt, on an event-by-event basis. [Memory Mapped]
MCSPI_SYST 0x00000000 This McSPI system register (MCSPI_SYST) is used to configure the system interconnect either internally to the peripheral bus or externally to the device I/O pads, when the module is configured in the system test (SYSTEST) mode. [Memory Mapped]
MCSPI_MODULCTRL 0x00000004 This McSPI module control register (MCSPI_MODULCTRL) is used to configure the serial port interface. [Memory Mapped]
MCSPI_CH0CONF 0x100713C4 The McSPI channel 0 configuration register (MCSPI_CH0CONF) is used to configure channel 0. [Memory Mapped]
MCSPI_CH0STAT 0x00000022 The McSPI channel 0 status register (MCSPI_CH0STAT) provides status information about the McSPI channel 0 FIFO transmit buffer register (MCSPI_TX0) and the McSPI channel 0 FIFO receive buffer register (MCSPI_RX0) of channel 0. [Memory Mapped]
MCSPI_CH0CTRL 0x00000001 Memory Mapped
MCSPI_TX0 0x00000000 Memory Mapped
MCSPI_RX0 0x00000000 The McSPI channel 0 FIFO receive buffer register (MCSPI_RX0) contains a single McSPI word received through the serial link. Little endian host access SPI 8 bit word on 0; big endian host accesses on 3h. [Memory Mapped]
MCSPI_CH1CONF 0x00060000 The McSPI channel 1 configuration register (MCSPI_CH1CONF) is used to configure channel 1. [Memory Mapped]
MCSPI_CH1STAT 0x00000000 The McSPI channel 1 status register (MCSPI_CH1STAT) provides status information about the McSPI channel 1 FIFO transmit buffer register (MCSPI_TX1) and the McSPI channel 1 FIFO receive buffer register (MCSPI_RX1) of channel 1. [Memory Mapped]
MCSPI_CH1CTRL 0x00000000 Memory Mapped
MCSPI_TX1 0x00000000 Memory Mapped
MCSPI_RX1 0x00000000 The McSPI channel 1 FIFO receive buffer register (MCSPI_RX1) contains a single McSPI word received through the serial link. Little endian host access SPI 8 bit word on 0; big endian host accesses on 3h. [Memory Mapped]
MCSPI_CH2CONF 0x00060000 The McSPI channel 2 configuration register (MCSPI_CH2CONF) is used to configure channel 2. [Memory Mapped]
MCSPI_CH2STAT 0x00000000 The McSPI channel 2 status register (MCSPI_CH2STAT) provides status information about the McSPI channel 2 FIFO transmit buffer register (MCSPI_TX2) and the McSPI channel 2 FIFO receive buffer register (MCSPI_RX2) of channel 2. [Memory Mapped]
MCSPI_CH2CTRL 0x00000000 Memory Mapped
MCSPI_TX2 0x00000000 Memory Mapped
MCSPI_RX2 0x00000000 The McSPI channel 2 FIFO receive buffer register (MCSPI_RX2) contains a single McSPI word received through the serial link. Little endian host access SPI 8 bit word on 0; big endian host accesses on 3h. [Memory Mapped]
MCSPI_CH3CONF 0x00060000 The McSPI channel 3 configuration register (MCSPI_CH3CONF) is used to configure channel 3. [Memory Mapped]
MCSPI_CH3STAT 0x00000000 The McSPI channel 3 status register (MCSPI_CH3STAT) provides status information about the McSPI channel 3 FIFO transmit buffer register (MCSPI_TX3) and the McSPI channel 3 FIFO receive buffer register (MCSPI_RX3) of channel 3. [Memory Mapped]
MCSPI_CH3CTRL 0x00000000 Memory Mapped
MCSPI_TX3 0x00000000 Memory Mapped
MCSPI_RX3 0x00000000 The McSPI channel 3 FIFO receive buffer register (MCSPI_RX3) contains a single McSPI word received through the serial link. Little endian host access SPI 8 bit word on 0; big endian host accesses on 3h. [Memory Mapped]
MCSPI_XFERLEVEL 0x00000000 The McSPI transfer levels register (MCSPI_XFERLEVEL) provides the transfer levels needed while using the FIFO buffer during transfer. [Memory Mapped]
MCSPI_DAFTX 0x00000000 The McSPI DMA address aligned FIFO transmitter register (MCSPI_DAFTX) contains the SPI words to transmit on the serial link when FIFO is used and the DMA address is aligned on 256 bit. This register is an image of one of the MCSPI_TX(i) registers corresponding to the channel which have its FIFO enabled. The SPI words are transferred with MSB first. See Chapter Access to data registers for the list of supported accesses. [Memory Mapped]
MCSPI_DAFRX 0x00000000 The McSPI DMA address aligned FIFO receiver register (MCSPI_DAFRX) contains the SPI words to received on the serial link when FIFO used and DMA address is aligned on 256 bit. This register is an image of one of MCSPI_RX(i) register corresponding to the channel which have its FIFO enabled. [Memory Mapped]
CPSR 0x6000019F Stores the status of interrupt enables and critical processor status signals [Core]
N 0 Stores bit 31 of the result of the instruction. In other words stores the sign of the number
Z 1 Is set to 1 if the result of the operation is zero else stays 0
C 1 Stores the value of the carry bit if it occurred in an addition or the borrow bit in a subtraction. In a shift stores the last bit shifted out.
V 0 Set to 1 if an overflow occurred
Q 0 Indicates whether an overflow or a saturation occurred in the enhanced DSP instructions
IT_1_0 00 IT state bits.
J 0 Java State Bit.
Reserved 0000 Reserved.
GE 0000 Greater than or equal bits
IT_7_2 000000 IT state bits
E 0 If set, data memory is interpreted as big-endian. If cleared data memory is interpreted as little-endian.
A 1 If set, any asynchronous abort is held pending until this bit is cleared.
I 1 If set, IRQ is disabled. If cleared IRQ is allowed
F 0 If set, FIQ is disabled. If cleared FIQ is allowed
T 0 If set ARM is in Thumb mode
M 11111 Mode of ARM
CM_PER_SPI1_CLKCTRL 0x00000002 This register manages the SPI1 clocks. [Memory Mapped]
Reserved1 00000000000000 Reserved
IDLEST 00 - Func Module idle status.
Reserved 00000000000000 Reserved
MODULEMODE 10 - ENABLE Control the way mandatory clocks are managed.
CM_PER_L4LS_CLKSTCTRL 0x1A006102 This register enables the domain power state transition. It controls the SW supervised clock domain state transition between ON-PER and ON-INPER states. It also hold one status bit per clock input of the domain. [Memory Mapped]
Reserved5 000 Reserved
CLKACTIVITY_TIMER6_GCLK 1 - Act This field indicates the state of the TIMER6 CLKTIMER clock in the domain.
CLKACTIVITY_TIMER5_GCLK 1 - Act This field indicates the state of the TIMER5 CLKTIMER clock in the domain.
Reserved6 0 Reserved.
CLKACTIVITY_SPI_GCLK 1 - Act This field indicates the state of the SPI_GCLK clock in the domain.
CLKACTIVITY_I2C_FCLK 0 - Inact This field indicates the state of the I2C _FCLK clock in the domain.
Reserved4 0 Reserved
Reserved7 0 Reserved.
CLKACTIVITY_GPIO_3_GDBCLK 0 - Inact This field indicates the state of the GPIO3_GDBCLK clock in the domain.
CLKACTIVITY_GPIO_2_GDBCLK 0 - Inact This field indicates the state of the GPIO2_ GDBCLK clock in the domain.
CLKACTIVITY_GPIO_1_GDBCLK 0 - Inact This field indicates the state of the GPIO1_GDBCLK clock in the domain.
Reserved8 0 Reserved.
CLKACTIVITY_LCDC_GCLK 0 - Inact This field indicates the state of the LCD clock in the domain.
CLKACTIVITY_TIMER4_GCLK 0 - Inact This field indicates the state of the TIMER4 CLKTIMER clock in the domain.
CLKACTIVITY_TIMER3_GCLK 0 - Inact This field indicates the state of the TIMER3 CLKTIMER clock in the domain.
CLKACTIVITY_TIMER2_GCLK 1 - Act This field indicates the state of the TIMER2 CLKTIMER clock in the domain.
CLKACTIVITY_TIMER7_GCLK 1 - Act This field indicates the state of the TIMER7 CLKTIMER clock in the domain.
Reserved3 0 Reserved
CLKACTIVITY_CAN_CLK 0 - Inact This field indicates the state of the CAN_CLK clock in the domain.
CLKACTIVITY_UART_GFCLK 0 - Inact This field indicates the state of the UART_GFCLK clock in the domain.
Reserved2 0 Reserved
CLKACTIVITY_L4LS_GCLK 1 - Act This field indicates the state of the L4LS_GCLK clock in the domain.
Reserved 000000 Reserved
CLKTRCTRL 10 - SW_WKUP Controls the clock state transition of the L4 SLOW clock domain in PER power domain.
CM_PER_L3S_CLKSTCTRL 0x0000000A This register enables the domain power state transition. It controls the SW supervised clock domain state transition between ON-ACTIVE and ON-INACTIVE states. It also hold one status bit per clock input of the domain. [Memory Mapped]
Reserved1 000000 Reserved
Reserved2 000000000000000 Reserved
Reserved4 0 Reserved
Reserved5 0 Reserved
Reserved3 0 Reserved
Reserved 000 Reserved
Reserved6 0 Reserved
CLKACTIVITY_L3S_GCLK 1 - Act This field indicates the state of the L3S_GCLK clock in the domain.
Reserved7 0 Reserved
CLKTRCTRL 10 - SW_WKUP Controls the clock state transition of the L3 Slow clock domain.
conf_mcasp0_aclkx 0x00000033 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_fsx 0x00000033 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_axr0 0x00000033 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_ahclkr 0x00000033 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_aclkr 0x00000027 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_fsr 0x00000027 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_axr1 0x00000027 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]
conf_mcasp0_ahclkx 0x00000027 See the device datasheet for information on default pin mux configurations. Note that the device ROM may change the default pin mux for certain pins based on the SYSBOOT mode settings. [Memory Mapped]