Other Parts Discussed in Thread: HALCOGEN, RM48L950
Hello,
I am trying to get the "example_spi_Master_Slave" example to work (from the "HALCoGen\v03.08.01\examples\RM48x" folder). I have ensured that I have:
CLK (J9 pin 6) to CLK (J10 pin 64)
SIMO (J9 pin 11) to SIMO (J10 pin 61)
SOMI (J9 pin 12) to SOMI (actually labelled as SIMI on my revision of the HDK, but J10 pin 59)
and CS0 (J9 pin 8) to CS (J10 pin 63)
I've checked my HalCoGen settings:
and below is my slightly modified code from the example (mostly just to control when it sends a packet and print out what was received.
#include "sys_common.h" /* USER CODE BEGIN (1) */ #include "spi.h" #include "sci.h" #include "ti_printf.h" /* USER CODE END */ /** @fn void main(void) * @brief Application main function * @note This function is empty by default. * * This function is called after startup. * The user can use this function to implement the application. */ /* USER CODE BEGIN (2) */ uint16 TX_Data_Master[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 }; uint16 TX_Data_Slave[16] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 }; uint16 RX_Data_Master[16] = { 0 }; uint16 RX_Data_Slave[16] = { 0 }; /* USER CODE END */ void main(void) { /* USER CODE BEGIN (3) */ char command1[2]; int i; spiDAT1_t dataconfig1_t; dataconfig1_t.CS_HOLD = FALSE; dataconfig1_t.WDEL = TRUE; dataconfig1_t.DFSEL = SPI_FMT_0; dataconfig1_t.CSNR = 0xFC; /* Enable CPU Interrupt through CPSR */ _enable_IRQ(); /* Initialize SPI Module Based on GUI configuration * SPI1 - Master ( SIMO, SOMI, CLK, CS0 ) * SPI2 - Slave ( SIMO, SOMI, CLK, CS0 ) * */ spiInit(); sciInit(); while(1) { ti_printf("waiting user input\r\n"); sciReceive(scilinREG,1, (unsigned char *)&command1[0]); sciSend(scilinREG,1,(unsigned char *)&command1[0]); /* Initiate SPI2 Transmit and Receive through Interrupt Mode */ spiSendAndGetData(spiREG2, &dataconfig1_t, 16, TX_Data_Slave, RX_Data_Slave); /* Initiate SPI1 Transmit and Receive through Polling Mode*/ spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master); for(i=0;i<=16;i++) { ti_printf("%d TX_Data_Slave: 0x%04x RX_Data_Slave: 0x%04x TX_Data_Master: 0x%04x RX_Data_Master: 0x%04x\r\n",i, TX_Data_Slave[i], RX_Data_Slave[i], TX_Data_Master[i], RX_Data_Master[i]); } } /* USER CODE END */ }
However what I see as a result is:
waiting user input
0 TX_Data_Slave: 0x0011 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0001 RX_Data_Master: 0xFFFF
1 TX_Data_Slave: 0x0012 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0002 RX_Data_Master: 0xFFFF
2 TX_Data_Slave: 0x0013 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0003 RX_Data_Master: 0xFFFF
3 TX_Data_Slave: 0x0014 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0004 RX_Data_Master: 0xFFFF
4 TX_Data_Slave: 0x0015 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0005 RX_Data_Master: 0xFFFF
5 TX_Data_Slave: 0x0016 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0006 RX_Data_Master: 0xFFFF
6 TX_Data_Slave: 0x0017 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0007 RX_Data_Master: 0xFFFF
7 TX_Data_Slave: 0x0018 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0008 RX_Data_Master: 0xFFFF
8 TX_Data_Slave: 0x0019 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0009 RX_Data_Master: 0xFFFF
9 TX_Data_Slave: 0x001A RX_Data_Slave: 0x0000 TX_Data_Master: 0x000A RX_Data_Master: 0xFFFF
10 TX_Data_Slave: 0x001B RX_Data_Slave: 0x0000 TX_Data_Master: 0x000B RX_Data_Master: 0xFFFF
11 TX_Data_Slave: 0x001C RX_Data_Slave: 0x0000 TX_Data_Master: 0x000C RX_Data_Master: 0xFFFF
12 TX_Data_Slave: 0x001D RX_Data_Slave: 0x0000 TX_Data_Master: 0x000D RX_Data_Master: 0xFFFF
13 TX_Data_Slave: 0x001E RX_Data_Slave: 0x0000 TX_Data_Master: 0x000E RX_Data_Master: 0xFFFF
14 TX_Data_Slave: 0x001F RX_Data_Slave: 0x0000 TX_Data_Master: 0x000F RX_Data_Master: 0xFFFF
15 TX_Data_Slave: 0x0020 RX_Data_Slave: 0x0000 TX_Data_Master: 0x0010 RX_Data_Master: 0xFFFF
16 TX_Data_Slave: 0xFFFF RX_Data_Slave: 0x83EF TX_Data_Master: 0x0011 RX_Data_Master: 0x0000
I've hooked up an osciloscope and I can see clearly that the slave select is never being pulled down, and as a result the slave never sends data back either. I also see (by commenting out the spiTansmitAndReceiveData function) that the tx and rx by interrupt mode doesn't function. I've attached a picture of the osciloscope output, order of the lines from top to bottom is clk, slave selected, SOMI, and SIMO. SIMO looks about right for the data I've input, and it looks like the slave select gets jumpy which to me would indicate some kind of bus-fighting for control of ss. But as shown in my halcogen settings, I've disabled the dir checkbox for the SPI2 port tab on CS.
Any suggestions on what I'm doing wrong?


