Tool/software:
Hello TI experts,
We are trying to establish communication between the TI j784s4 eva board and a customer's transceiver board over SPI.
We have tested the transceiver board beforehand using Total Phase's Aardvark and have confirmed that the hardware behaves as intended.
We are using Linux + RTOS version 10 of the SDK.
As far as the hardware connection goes, we have connected the pins from J26 as following:
SPI5_CLK -> SCLK
SPI5_D0 -> MISO
SPI5_D1 -> MOSI (we tried the other way around as well, connecting D1 to MISO)
SPI_CS1 -> open
SPI_CS0 -> SS (we tried the other way around as well, connecting CS1 to SS)
GND -> GND
In the code we have (perhaps unsuccessfully) changed the values of CANUART_MUX1_SEL0 and CANUART_MUX2_SEL0 in order to select the signals for SPI from the schematic.
The SPI code is located on rtos_pdk/packages/ti/board/src/devices/common/common.c
void SPI_test() { printf("### SPI_test start ###\n"); printf("### SPI_test setting up the board ###\n"); /* Setting up for pinmux and uart */ Board_STATUS ret; Board_initCfg boardCfg; boardCfg = BOARD_INIT_MODULE_CLOCK | BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_UART_STDIO; ret = Board_init(boardCfg); printf("### Board status: %x ###\n", ret); printf("### SPI_test board init finished ###\n"); printf("### SPI_test configuring pins ###\n"); Board_IoExpCfg_t ioExpCfg[PINMUX_SIZE]= { /*Set CANUART_MUX1_SEL0 to LEVEL_HIGH */ { .i2cInst = BOARD_I2C_IOEXP_DEVICE2_INSTANCE, .socDomain = BOARD_SOC_DOMAIN_MAIN, .slaveAddr = BOARD_I2C_IOEXP_DEVICE2_ADDR, .enableIntr = false, .ioExpType = THREE_PORT_IOEXP, .portNum = PORTNUM_1, .pinNum = PIN_NUM_5, .signalLevel = GPIO_SIGNAL_LEVEL_HIGH, }, /*Set CANUART_MUX2_SEL0 to LEVEL_HIGH */ { .i2cInst = BOARD_I2C_IOEXP_DEVICE2_INSTANCE, .socDomain = BOARD_SOC_DOMAIN_MAIN, .slaveAddr = BOARD_I2C_IOEXP_DEVICE2_ADDR, .enableIntr = false, .ioExpType = THREE_PORT_IOEXP, .portNum = PORTNUM_1, .pinNum = PIN_NUM_6, .signalLevel = GPIO_SIGNAL_LEVEL_HIGH, } }; uint32_t i; for (i=0; i < PINMUX_SIZE; i++) { Board_control(BOARD_CTRL_CMD_SET_IO_EXP_PIN_OUT, &ioExpCfg[i]); } printf("### SPI_test configuring pins - DONE ###\n"); uint32_t domain = SPI_MCSPI_DOMAIN_MAIN; /* MAIN domain */ uint32_t instance = 5; /* SPI5 on j784 */ printf("### Calling SPI_init ###\n"); SPI_init(); printf("### SPI_init finished ###\n"); SPI_Params spiParams; SPI_Params_init(&spiParams); /* defaults are fine for the most part */ spiParams.transferTimeout = 10000; printf("### spiParams.transferTimeout: %x ###\n", spiParams.transferTimeout); printf("### Calling SPI_open ###\n"); SPI_Handle handle = SPI_open(domain, instance, &spiParams); printf("### SPI_open finished ###\n"); uint16_t txBuf[1] = {0xBABA}; uint16_t rxBuf[1] = {0}; SPI_Transaction spiTransaction = { .count = 1, .txDmaBuf = 0, .rxDmaBuf = 0, .txBuf = (void *)txBuf, .rxBuf = (void *)rxBuf, .arg = NULL }; printf("### Calling SPI_transfer ###\n"); bool transferOK = SPI_transfer(handle, &spiTransaction); if(!transferOK) { printf("### SPI_transfer finished unsuccessfully ###\n"); } else { printf("### SPI_transfer finished successfully ###\n"); } printf("### SPI read data: %x \n", rxBuf[0]); printf("### Calling SPI_close ###\n"); SPI_close(handle); printf("### SPI_close finished ###\n"); printf("### SPI_test end ###\n"); }
This function is called from the app_r5f_target_kernel_bringup app.
The rest of the files only contain added prints, so they should not have any impact on the SPI transfer itself.
There are no other changes in the SDK, besides the ones mentioned here.
Here is the log file generated from the app:
[MCU2_0] 62.056466 s: [MCU2_0] 62.056531 s: app_r5f_target_kernel_bringup_create -13- 175 [MCU2_0] 62.056565 s: ### Test app - SPI - app_r5f_target_kernel_bringup_create ### [MCU2_0] 62.056591 s: [MCU2_0] 62.056611 s: app_r5f_target_kernel_bringup_create 180 Loading [./in_file.txt] ... Running graph ... [MCU2_0] 62.061628 s: app_r5f_target_kernel_bringup 148 [MCU2_0] 62.061658 s: ### Test app - SPI - app_r5f_target_kernel_bringup ### [MCU2_0] 62.061687 s: ### app_r5f_target_kernel_bringup - calling SPI_test() ### [MCU2_0] 62.061713 s: ### SPI_test start ### [MCU2_0] 62.061731 s: ### SPI_test setting up the board ### [MCU2_0] 62.068079 s: ### Board status: 0 ### [MCU2_0] 62.068109 s: ### SPI_test board init finished ### [MCU2_0] 62.068133 s: ### SPI_test configuring pins ### [MCU2_0] 62.159776 s: ### SPI_test configuring pins - DONE ### [MCU2_0] 62.159835 s: ### Calling SPI_init ### [MCU2_0] 62.159930 s: ### SPI_init finished ### [MCU2_0] 62.159963 s: ### spiParams.transferTimeout: 2710 ### [MCU2_0] 62.159986 s: ### Calling SPI_open ### [MCU2_0] 62.160064 s: ### handle_p = a36a6310### SPI_open finished ### [MCU2_0] 62.160091 s: ### Calling SPI_transfer ### [MCU2_0] 62.160110 s: ### SPI_transfer start ### [MCU2_0] 62.160130 s: ### SPI_transfer accessing function pointer ### [MCU2_0] 62.160158 s: ### fxnTablePtr value: a36d1994 [MCU2_0] 62.160186 s: ### transferFxn value: a34f47d9 [MCU2_0] 62.160207 s: $$$ SPI_transfer_v1 start [MCU2_0] 62.160227 s: $$$ MCSPI_get_handle started [MCU2_0] 62.160248 s: $$$ MCSPI_get_handle finished [MCU2_0] 62.160268 s: $$$ SPI_transfer_v1 calling MCSPI_transfer_v1 [MCU2_0] 62.160292 s: $$$ MCSPI_transfer_v1 start [MCU2_0] 62.160312 s: $$$ MCSPI_transfer_v1 acquiring lock [MCU2_0] 62.160334 s: $$$ MCSPI_transfer_v1 SPI_osalPendLock finished [MCU2_0] 62.160359 s: $$$ MCSPI_transfer_v1 lock acquired [MCU2_0] 62.160380 s: $$$ MCSPI_transfer_v1 SPI_TRANSFER_STARTED [MCU2_0] 62.160403 s: $$$ MCSPI_transfer_v1 chObj->transaction [MCU2_0] 62.160426 s: $$$ MCSPI_transfer_v1 chObj->transaction - DONE! [MCU2_0] 62.160450 s: $$$ MCSPI_transfer_v1 MCSPI_primeTransfer_v1 [MCU2_0] 62.160473 s: $$$ MCSPI_primeTransfer_v1 McSPIChannelEnable [MCU2_0] 62.160497 s: $$$ MCSPI_primeTransfer_v1 McSPIChannelEnable - DONE [MCU2_0] 62.160522 s: $$$ MCSPI_primeTransfer_v1 MCSPI_xferSetup_v1 [MCU2_0] 62.160550 s: $$$ MCSPI_primeTransfer_v1 MCSPI_xferSetup_v1 - DONE [MCU2_0] 62.160576 s: $$$ MCSPI_primeTransfer_v1 Interrupt mode [MCU2_0] 62.160601 s: $$$ MCSPI_transfer_v1 MCSPI_primeTransfer_v1 - finished [MCU2_0] 62.160628 s: $$$ MCSPI_transfer_v1 SPI_osalPendLock chObj->operMode [MCU2_0] 62.160667 s: $$$ MCSPI_transfer_v1 SPI_osalPendLock object->transferComplete a335d950 [MCU2_0] 62.160711 s: $$$ MCSPI_transfer_v1 SPI_osalPendLock chObj->spiParams.transferTimeout 2710 Saving [./out_file.txt] ... Done !!! app_r5f_kernel_bringup_unregister 273 app_r5f_kernel_bringup_unregister 289 72.160963 s: VX_ZONE_INIT:[tivxHostDeInitLocal:120] De-Initialization Done for HOST !!! [MCU2_0] 72.159774 s: $$$ MCSPI_transfer_v1 SPI_osalPendLock finished [MCU2_0] 72.159834 s: $$$ MCSPI_transfer_v1 SemaphoreP_TIMEOUT 72.165395 s: VX_ZONE_INIT:[tivxDeInitLocal:206] De-Initialization Done !!! [MCU2_0] 72.159864 s: $$$ MCSPI_transfer_v1 McSPIIntStatusClear APP: Deinit ... !!! REMOTE_SERVICE: Deinit ... !!! [MCU2_0] 72.159890 s: $$$ MCSPI_transfer_v1 McSPIChannelDisable [MCU2_0] 72.159913 s: $$$ MCSPI_transfer_v1 SPI_osalPostLock [MCU2_0] 72.159936 s: $$$ MCSPI_transfer_v1 end [MCU2_0] 72.159955 s: $$$ SPI_transfer_v1 MCSPI_transfer_v1 finished [MCU2_0] 72.159978 s: $$$ SPI_transfer_v1 finished [MCU2_0] 72.159998 s: ### SPI_transfer ended ### [MCU2_0] 72.160017 s: ### SPI_transfer finished unsuccessfully ### [MCU2_0] 72.160045 s: ### SPI read data: 0 [MCU2_0] 72.160064 s: ### Calling SPI_close ### [MCU2_0] 72.160099 s: ### SPI_close finished ### [MCU2_0] 72.160121 s: ### SPI_test end ### [MCU2_0] 72.160140 s: ### app_r5f_target_kernel_bringup - SPI_test() finished ### [MCU2_0] 72.160551 s: app_r5f_target_kernel_bringup_delete 196 [MCU2_0] 72.160584 s: ### Test app - SPI - app_r5f_target_kernel_bringup_delete ### REMOTE_SERVICE: Deinit ... Done !!! 72.166350 s: IPC: Deinit ... !!! 72.167139 s: IPC: DeInit ... Done !!! 72.167161 s: MEM: Deinit ... !!! 72.167171 s: DDR_SHARED_MEM: Alloc's: 0 alloc's of 0 bytes 72.167179 s: DDR_SHARED_MEM: Free's : 0 free's of 0 bytes 72.167185 s: DDR_SHARED_MEM: Open's : 0 allocs of 0 bytes 72.167196 s: MEM: Deinit ... Done !!! APP: Deinit ... Done !!! root@j784s4-evm:/opt/vision_apps#
Note: we have also tried with both longer and shorter timeout values, always with the same result.
Are there any obvious steps that we are missing? Or are we just using the SPI driver API incorrectly?
Best regards,
Stefan Pijetlovic