Other Parts Discussed in Thread: SYSCONFIG,
Tool/software: Code Composer Studio
Hello Everybody!
I would like to connect something to an SPI port of IDK.
I can send but can not receive.
I have found J20 connector where signals of MCSPI1 port are available.
spiInitCfg driver table has 5 entries:
Index |
baseAddr |
SPI port |
0 |
0x40300000 |
MCU_MCSPI0 |
1 |
0x40310000 |
MCU_MCSPI1 |
2 |
0x40320000 |
MCU_MCSPI2 |
3 |
0 |
|
4 |
0 |
|
I have hacked the table by copying index 2 to index 3 and set the base address to MCSPI1 to reach that port:
SPI_v1_HWAttrs spi_cfg; SPI_socGetInitCfg(2, &spi_cfg); spi_cfg.baseAddr = CSL_MCSPI1_CFG_BASE; SPI_socSetInitCfg(3, &spi_cfg);
And here is the initialization of SPI port:
SPI_init(); /* SPI initialization */ SPI_socGetInitCfg(instance, &config); /* configuration example master see: * ti/pdk_am65xx_1_0_7/packages/ti/drv/spi/example/mcspi_slavemode */ config.enableIntr = false; config.chNum = 0U; SPI_socSetInitCfg(instance, &config); /* Initialize SPI handle */ SPI_Params_init(¶ms); params.transferMode = SPI_MODE_BLOCKING; params.transferCallbackFxn = NULL; params.transferTimeout = SemaphoreP_WAIT_FOREVER; params.bitRate = 12000000U; handle = SPI_open(instance, ¶ms);
And then I sent data using Index 3 and could see CLK, CS and MOSI signals on pins of J20 connector by scope.
I used bool SPI_transfer(SPI_Handle handle, SPI_Transaction *spiTrans) fuction
Till now it is still OK.
Then I wanted to test the SPI input too, therefore I connected MISO input to MOSI output with a jumper (J20/2 – J20/1) and expected that the transfer function gets back the sent data.
uint32_t loopCtr = 0; uint32_t readbackValue = 0x55555555U; while (true) { loopCtr++; ret = spi.transmit((uint8_t *)&loopCtr, (uint8_t *)&readbackValue, sizeof(loopCtr)); if ( loopCtr == readbackValue ) { gpio.reset(USER_LED1); gpio.toggle(USER_LED0); } else { gpio.reset(USER_LED0); gpio.toggle(USER_LED1); } Task_sleep(20); /* suspend task*/ }
(spi.transmit function calls SPI_transfer of course)
And here is my problem: I got 0 in readbackValue instead of the sent value always.
Connection to J20/2 pin is OK, I could see MOSI signal on it when changed DPE1 & DPE0 bits of MCSPI_CHCONF_1 register from 0b10 to 0b01 (or 0b00)
I suppose that input selector (IS) bit of MCSPI_CHCONF_1 can be used for internal loopback.
Here are my results
IS |
DPE1 |
DPE0 |
J20/1 |
J20/2 |
redbackValue |
1 |
0 |
0 |
OK |
OK |
0 |
0 |
0 |
0 |
OK |
OK |
0 |
1 |
1 |
0 |
OK |
- |
0 |
0 |
1 |
0 |
OK |
- |
0 |
1 |
0 |
1 |
- |
OK |
0 |
0 |
0 |
1 |
- |
OK |
0 |
OK means that MOSI signal was seen on that pin by scope.
- means inactivity, i.e. low level on that pin.
And I have never get back good value.
Memory browser window was active during my debug session becasue I watched / changed the SPI registers there.
Debugger may disturb operation when it reads registers unexpectedly (to update the browser window) therefore I have turned it off and repeated the SPI transfer, but got the same 0 result.
Register content from memory bowser @ 0x02110100
MCSPI1_CFG_MCSPI_REVISION
0000002B 00000000 00000000 00000000
MCSPI1_CFG_MCSPI_SYSCONFIG
00000308
MCSPI1_CFG_MCSPI_SYSSTATUS
00000001
MCSPI1_CFG_MCSPI_IRQSTATUS
00020001
MCSPI1_CFG_MCSPI_IRQENABLE
00000000
MCSPI1_CFG_MCSPI_WAKEUPENABLE
00000000
MCSPI1_CFG_MCSPI_SYST
00000000
MCSPI1_CFG_MCSPI_MODULCTRL
00000001
MCSPI1_CFG_MCSPI_CHCONF_0
180603C8
MCSPI1_CFG_MCSPI_CHSTAT_0
0000002E
MCSPI1_CFG_MCSPI_CHCTRL_0
00000000
MCSPI1_CFG_MCSPI_TX_0
00000000
MCSPI1_CFG_MCSPI_RX_0
00000000
What is wrong here? Howe can I receive on SPI?
Best regards
Kalman