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

Diagnosing SPI issue with MSP430FR4133 and DLP-7970ABP (TRF7970A Booster Pack)

$
0
0

Hello,

I'm trying to use the DLP-7970ABP booster pack to read RFID cards to a MSP430FR4133. To get a basic understanding of the system I'm attempting to modify DLP's demo source code to be compatible with the FR4133. I'm a bit stumped with an issue regarding the SPI communication. It would appear that I am able to send the first command but do not get a UCB0TXIFG flag set to indicate the TRF7970A is ready to receive the next command.

int main(void) {
	WDTCTL = WDT_ADLY_16; // @Jon check -- WDT 350ms ACLK=1.5kHz, interval timer

	SFRIE1 |= WDTIE; // enable WDT interrupt

	P8DIR |= BIT2; // P2.1 output, slave select port
	P8OUT |= BIT2; // P2.1 set to high

	P8DIR |= BIT3; // P2.2 output, TRF enable
	P8OUT |= BIT3; // P2.2 set to high

	__delay_cycles(26000); // appx 2ms delay to let 7970 system clock start

	// P2DIR |= BIT2; already done
	P2DIR &= ~BIT5; // P2.0 IRQ input
	P2IES &= ~BIT5; // P2.0 edge select

	UCB0CTL1 |= UCSWRST; // sw reset enable
	UCB0CTL0 |=  UCMSB + UCMST + UCSYNC;    // 3-pin, 8-bit SPI master
	UCB0CTL1 |= UCSSEL__SMCLK;                       // SMCLK
	UCB0BR0 |= 8;                                    // SPI clock frequency = SMCLK / 8 (was 8mhz/4 now 16/8)
	UCB0BR1 = 0;
	// GPIO Config
	P5SEL0 |= BIT1 + BIT2 + BIT3; // 1.5 6 7 to peripheral

	UCB0CTL1 &= ~UCSWRST;                            // **Initialize USCI state machine**

	P1OUT &= ~(BIT3 | BIT4 | BIT5); // set LED to low (2.3, 4, 5)
	P1DIR |= (BIT3 | BIT4 | BIT5);  // set 2.3, 4, 5 to output

	uint8_t command[2]; // why treat this as 2 8 bits instead of 1 16...
	command[0] = 0; // original code should clear stuff
	command[1] = 0;
	command[0] = 0x03; // "SOFT_INIT"

	command[0] = (0x80 | command[0]); // bit7 = 1
	command[0] = (0x9f & command[0]); // bit 5,6 = 0
	P8OUT &= ~BIT2; // slave select to low
	// USCI_BO TX buffer ready?
	while (!(UCB0IFG & UCTXIFG));
	UCB0TXBUF = command[0];
	while (UCB0STAT & UCBUSY);
	temp = UCB0RXBUF;
	P8OUT |= BIT2; // slave select back to high

	command[0] = 0x00; // "IDLE"

	command[0] = (0x80 | command[0]);
	command[0] = (0x9f & command[0]);
	P8OUT &= ~BIT2; // slave select to low
	// USCI_BO TX buffer ready?
	while (!(UCB0IFG & UCTXIFG));
	UCB0TXBUF = command[0];
	while (UCB0STAT & UCBUSY);
	temp = UCB0RXBUF;
	P8OUT |= BIT2; // slave select back to high

	command[0] = 0x09; // modular control
	command[1] = 0x01;

	P8OUT &= ~BIT2; // slave select low, SPI mode

	command[0] = (0x1f & command[0]); // force first 3 bits to zero
	while (!(UCB0IFG & UCTXIFG)); // TX buffer ready?
	UCB0TXBUF = command[0];
	while (UCB0STAT & UCBUSY);
	temp = UCB0RXBUF;


	command[1] = (0x1f & command[1]); // force first 3 bits to zero
	while (!(UCB0IFG & UCTXIFG)); // TX buffer ready?
	UCB0TXBUF = command[1];
	while (UCB0STAT & UCBUSY);
	temp = UCB0RXBUF;

	P8OUT |= BIT2; // slave select back on, exit spi mode

	while (1); // catch stuff to prevent unpredictable execution, debug purposes

}

As far as I can tell I've made all the correct modifications for the register names and corresponding bits on the booster pack pin map, but my code gets hung up on the second

while (!(UCB0IFG & UCTXIFG));

Any tips for troubleshooting?

Thanks,

- Jonathan


Viewing all articles
Browse latest Browse all 21927

Trending Articles



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