I wrote a blinking code over spi. (i wrote same code in stm32). I have a ancher connected to stm. Normally if stm tag transmit data, i read the data from stm tag. But if i transmit same data with msp430, i don’t read the data from stm anchor. My tag code is :
dwt_writetxdata(sizeof(blink_msg), blink_msg, 0);
dwt_writetxfctrl(sizeof(blink_msg), 0, 0);
dwt_starttx(DWT_START_TX_IMMEDIATE);
And i read spi data with logic analyzer.
STM tag spi data = 89 01 13 00 80 05 40 16 00 8D 02
MSP tag spi data = 89 01 13 00 88 05 40 00 00 8D 02
What is the reason of difference between these two data and why I can not detect the data I sent over msp from stm.
[code]#include “mhrrm_spi.h”
#include <stdint.h>
#include <msp430.h>
void spi_init() {
P1DIR |= BIT0;
P3SEL = BIT0 + BIT4 + BIT5;
P3SEL2 = ~(BIT0 + BIT4 + BIT5); // Set P3.5, P3.6, and P3.7 as SPI
UCA0CTL1 |= UCSWRST; //Reset EUSCI
UCA0CTL0 |= UCCKPH | // Set clock phase
UCMSB | // MSB first
UCMST | // Set as SPI master
UCSYNC; // Set as synchronous mode
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x18;
UCA0BR1 = 0;
UCA0MCTL = 0;
UCA0CTL1 &= ~UCSWRST; // Initialize USCI
IFG2 &= ~UCA0TXIFG; // Clear TXIFG flag
IFG2 &= ~UCA0RXIFG; // Clear RXIFG flag
IE2 |= UCA0TXIE; // Enable TX interrupt
IE2 |= UCA0RXIE; // Enable RX interrupt
}
void BRD_spi_set_high(void)
{
UCA0CTL1 |= UCSWRST;
UCA0BR0 |= 0x00;
UCA0BR1 = 0;
UCA0CTL1 &= ~UCSWRST;
}
void BRD_spi_set_low(void)
{
UCA0CTL1 |= UCSWRST;
UCA0BR0 |= 0x08;
UCA0BR1 = 0;
UCA0CTL1 &= ~UCSWRST;
}
uint8_t spi_write_byte(uint8_t data) {
while(0 == (IFG2 & UCA0TXIFG));
UCA0TXBUF = data;
while(0 ==(IFG2 & UCA0RXIFG));
data = UCA0RXBUF;
return data;
}
uint8_t spi_read_byte() {
/* Write dummy data to receive the current byte */
return spi_write_byte(0xFFu);
}
void spi_write(const uint8_t *p_data, uint8_t length) {
uint8_t index;
uint8_t *p_write;
p_write = (uint8_t *)p_data;
//P1OUT &= ~BIT0;
for (index = 0; index < length; index++) {
spi_write_byte(p_write[index]);
}
//P1OUT |= BIT0;
}
void spi_read(const uint8_t *p_data, uint8_t length) {
uint8_t index;
uint8_t *p_read;
p_read = (uint8_t *)p_data;
//P1OUT &= ~BIT0;
for (index = 0; index < length; index++) {
p_read[index] = spi_read_byte();
}
//P1OUT |= BIT0;
}[/code]
is there anyone who can say my problem???