Part Number: XTCIEVMK2LX
Tool/software: TI-RTOS
Hello, experts.
I'm still struggling for getting an ADC board (DEV-ADC34J22) work with XTCIEVMK2LX. (Refer this.)
According to the user guide of the ADC board, it has two chips that can be configured via SPI interface: ADC34J22 and LMK04828B.
The board is connected to XTCIEVMK2LX with FMC1, but not directly, through an adapter board (FMC to HSMC) because the ADC board has an HSMC connector only.
It seems there are three SPI interfaces on XTCIEVMK2LX, and the SPI1 seems to be the one that connects to FMC according to the data sheet.
I don't know how to select a chip I want to configure on the ADC board, but anyway I decided to send the default data (provided in the user guide) to the board over FMC using SPI communication in C.
I found the driver library for SPI, and confirmed it works well by running the test application that writes some data to the NOR flash. Referring the example code, I wrote my own code as follows (some code is omited):
void Board_initSPI(void) { Board_initCfg boardCfg; SPI_v0_HWAttrs spi_cfg; /* Get the default SPI init configurations */ SPI_socGetInitCfg(SPI_PORT, &spi_cfg); // SPI_PORT = 1 /* Modify the default SPI configurations if necessary */ spi_cfg.intNum = 10; // Set this to avoid the 'Hwi already defined' error. /* Set the default SPI init configurations */ SPI_socSetInitCfg(SPI_PORT, &spi_cfg); boardCfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_MODULE_CLOCK | BOARD_INIT_UART_STDIO; Board_init(boardCfg); } void send_config(UArg arg0, UArg arg1) { SPI_Handle spiHandle; SPI_Params spiParams; SPI_Transaction spiTransactionAdc; SPI_Transaction spiTransactionLmk; SPI_Params_init(&spiParams); spiParams.transferTimeout = 10; spiHandle = SPI_open(SPI_PORT, &spiParams); if (!spiHandle) { System_printf("SPI_open failed.\n"); } else { System_printf("SPI_open success.\n"); } spiTransactionAdc.count = sizeof(adcDefaultData); spiTransactionAdc.txBuf = adcDefaultData; spiTransactionAdc.rxBuf = NULL; if (!SPI_transfer(spiHandle, &spiTransactionAdc)) { System_printf("Sending ADC default data failed.\n"); } spiTransactionLmk.count = sizeof(lmkDefaultData); spiTransactionLmk.txBuf = lmkDefaultData; spiTransactionLmk.rxBuf = NULL; if (!SPI_transfer(spiHandle, &spiTransactionLmk)) { System_printf("Sending LMK default data failed.\n"); } SPI_close(spiHandle); BIOS_exit(0); } /* * ======== main ======== */ Int main(void) { System_atexit(AtExit); System_printf("entering Board_initSPI()...\n"); Board_initSPI(); System_printf("exiting Board_initSPI()...\n"); System_printf("entering SPI_init()...\n"); SPI_init(); System_printf("exiting SPI_init()...\n"); System_printf("entering BIOS...\n"); BIOS_start(); return (0); } void AtExit(Int stat) { System_printf("exiting BIOS..."); return; }
The cfg file is as follows:
var Settings = xdc.useModule('ti.board.Settings'); var BIOS = xdc.useModule('ti.sysbios.BIOS'); var ti_drv_spi_Settings = xdc.useModule('ti.drv.spi.Settings'); var ti_drv_uart_Settings = xdc.useModule('ti.drv.uart.Settings'); var ti_osal_Settings = xdc.useModule('ti.osal.Settings'); var ti_csl_Settings = xdc.useModule('ti.csl.Settings'); var Task = xdc.useModule('ti.sysbios.knl.Task'); var System = xdc.useModule('xdc.runtime.System'); var SysStd = xdc.useModule('xdc.runtime.SysStd'); var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem'); var Memory = xdc.useModule('xdc.runtime.Memory'); var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf'); System.SupportProxy = SysStd; var CpIntc = xdc.useModule('ti.sysbios.family.c66.tci66xx.CpIntc'); Settings.boardName = "evmK2L"; ti_drv_spi_Settings.socType = "k2l"; ti_drv_uart_Settings.socType = "k2l"; ti_osal_Settings.osType = "tirtos"; ti_osal_Settings.socType = "k2l"; ti_csl_Settings.deviceType = "k2l"; var task0Params = new Task.Params(); task0Params.instance.name = "task0"; task0Params.stackSize = 4096; Program.global.task0 = Task.create("&send_config", task0Params); Task.numPriorities = 4; var heapMem0Params = new HeapMem.Params(); heapMem0Params.instance.name = "heapMem0"; heapMem0Params.size = 204800; Program.global.heapMem0 = HeapMem.create(heapMem0Params); Memory.defaultHeapInstance = Program.global.heapMem0;
There's no problem to build and launch the code, but when I click the "Resume" button on CCS, it's hung. The status of the debug probe shows "Running." The output is as follows:
entering Board_initSPI()...
exiting Board_initSPI()...
entering SPI_init()...
exiting SPI_init()...
entering BIOS...
SPI_open success.
It seems the program is hung when trying SPI_transfer().
I'm not sure whether it's a correct way to configure the chips on the ADC board or not, actually. If I'm doing it in totally wrong way, please teach me what's the correct way. The ultimate goal is to get data from the ADC board in a programmatic way. I'm still not sure if I can make it with the hardware configuration, but anyway I thought the ADC board must be configured first before using RF SDK tools to access it.
Thank you very much!
Huioon