Hello,
I am trying to run the MQX 4.1 SPI demo project on my tower system using the k60f120m board. I went into my user_config.h file and enabled SPI0,SPI1, and SPI2 by setting them to 1. Also at the bottom of that file there are a few tabs (bsp, MQX, rtcs...user_config.h). I went to the bsp tab and changed bsp_enable_spix from false to true for each of the SPI options. The program compiles without error, but there is a warning message. It was an error, but after my changes it is now a warning. The flagged code is below.
#elif BSP_SPI_MEMORY_CHANNEL == 2
#if ! BSPCFG_ENABLE_SPI2
#error This application requires BSPCFG_ENABLE_SPI2 defined non-zero in user_config.h. Please recompile kernel with this option.
I also went into the k60f120m.h files and set where it defined the SPI connections to 1 from 0s. As shown below.
** Enable SPI2 device
** MGCT: <option type="bool"/>
*/
#ifndef BSPCFG_ENABLE_SPI2
#define BSPCFG_ENABLE_SPI2
The program compiles and runs, but an error message saying Error opening SPI driver appears. The code which throws the error message is below.
spifd = fopen (TEST_CHANNEL, NULL);
if (NULL == spifd)
{
printf ("Error opening SPI driver!\n");
_time_delay (200L);
_task_block ();
}
Hello Michael,
I executed the folowing steps to switch to SPI2:
1. One change in the twrk60f120m.h to define BSP_SPI_MEMORY_CHANNEL as 2
2. two changes in the user_config.h to disable BSPCFG_ENABLE_SPI0 and enable BSPCFG_ENABLE_SPI2
3. A new build of the MQX
4. A new build of the spi example program
In addition please verify the below configuration in the that you have the below configuration in the init_gpio.c file.
Case 2:
/* Configure GPIOD for DSPI2 peripheral function */
pctl = (PORT_MemMapPtr)PORTB_BASE_PTR;
pctl->PCR[20] = PORT_PCR_MUX(2); /* DSPI2.PCS0 */
pctl->PCR[21] = PORT_PCR_MUX(2); /* DSPI2.SCK */
pctl->PCR[22] = PORT_PCR_MUX(2); /* DSPI2.SOUT */
pctl->PCR[23] = PORT_PCR_MUX(2); /* DSPI2.SIN */
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I appreciate the help, but unfortunately I can still not get it to work. I disabled the SPI0 and SPI1 connections in both the user_config.c and twrk60f120.m.h files and left SPI2 to 1. Should I be leaving any of the SPI0/SPI1 options in the twrk60f120m.h file set to 1, or should they be 0? An image below shows where I changed them. Also my int_gpio.c has a warning of pctl may be used uninitalized in this function. The error is shown below.