Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 22001

RTOS/MSP430F5529: SPI slave mode: the SPI_transfer() funtion issue

$
0
0

Part Number:MSP430F5529

Tool/software: TI-RTOS

hi 

my version:

ccsv7.4

tidriver_msp43x_2_20_00_08

bios_6_46_00_23

I'm still using the EXP_MSP430F5529LP development board to verify SPI communication, Recently , I'm stuck in the SPI_transfer() function. config spi slave mode under TI-RTOS.

target: SPI master sends a byte, spi slave  judge the byte and to continue receiving or sending data.

here is my config

    /* Create I2C for usage */
    SPI_Params_init(&spiB1_slave_Params);
    spiB1_slave_Params.transferMode          = SPI_MODE_BLOCKING;
    spiB1_slave_Params.mode                       = SPI_SLAVE;
    spiB1_slave_Params.dataSize                 = 8;

    spiB1_slave = SPI_open(Board_SPIB1_SLAVE, &spiB1_slave_Params);
    if (spiB1_slave == NULL) {
        System_abort("Error Initializing SPI B1\n");
    }else {
        System_printf("SPI B1 Initialized!\n");
    }
    System_flush();


issue    I use the following two pieces of code for data reception validation

	//code 1
	//disposable recept 3 bytes
        SPI_Transaction spiTransaction;        
		
	spiTransaction.txBuf = NULL;
	spiTransaction.rxBuf = rxBuf;
	spiTransaction.count = 3;

	if (SPI_transfer(spiB1_slave, &spiTransaction) == NULL) {
		System_printf("SPIB1_SendData SPI Bus fault\n");
		System_flush();
	}
	System_printf("%s\r\n",rxBuf);
	System_flush();
	
	
	
	//code 2
	//first recept 1 bytes
        SPI_Transaction spiTransaction;        
		
	spiTransaction.txBuf = NULL;
	spiTransaction.rxBuf = rxBuf;
	spiTransaction.count = 1;

	if (SPI_transfer(spiB1_slave, &spiTransaction) == NULL) {
		System_printf("SPIB1_SendData SPI Bus fault\n");
		System_flush();
	}
	
	//continue recept 2 bytes
	spiTransaction.txBuf = NULL;
	spiTransaction.rxBuf = rxBuf+1;
	spiTransaction.count = 2;

	if (SPI_transfer(spiB1_slave, &spiTransaction) == NULL) {
		System_printf("SPIB1_SendData SPI Bus fault\n");
		System_flush();
	}
	System_printf("%s\r\n",rxBuf);
	System_flush();	

result  

When I using the spi master send three bytes at a time, code 1 receive data is ok,  buf code 1  will block in the second SPI_transfer();

When I using the spi master send three bytes each byte is one second apart,  code 1 2 receive data both is ok.

Why is this problem?

best wishes

xc.mo


Viewing all articles
Browse latest Browse all 22001

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>