Hi e2e,
I am having problems trying to communicate the MSP430FR2433 with the PN532 via SPI. The question is that I want to obtain the version of the PN532, for that, I must send the following command to the PN532: {0X00,0X00,0XFF,0X02,0XFE,0XD4,0X02,0X2A,0X00}. After sending that command, you should receive a response from the PN532 that should be as follows: [ 00 00 FF 00 FF 00 ]
and [ 00 00 FF D5 03 32 01 06 07 E8 ].
The question is that I manage to send the command well but I receive 0xFF all the time... I don't know where the failure can be.
#include "nfc.h"
#include "msp430.h"
unsigned char RXData =0;
unsigned char TXData =0;
unsigned char nfc_buff[NFC_CMD_BUF_LEN];
static const unsigned char version_buff[35] = {0X00,0X00,0XFF,0X02,0XFE,0XD4,0X02,0X2A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,};
void Configuracion_SPI_B(void);
unsigned int get_version(void);
void PIN_config(void);
unsigned int get_version(void);
int main()
{
WDTCTL = WDTPW | WDTHOLD;
PIN_config();
Configuracion_SPI_B();
PM5CTL0 &= ~LOCKLPM5;
__enable_interrupt();
while(1)
{
get_version();
while(1);
}
}
void Configuracion_SPI_B(void)
{
UCB0CTLW0 |= UCSWRST;
UCB0CTLW0 |= UCMST|UCSYNC|UCCKPL|UCMSB|UCMODE_1|UCSTEM;
UCB0CTLW0 |= UCSSEL__SMCLK;
UCB0CTLW0 &= ~UCSWRST;
P1SEL0 |= BIT4 | BIT5 | BIT6 | BIT7 | BIT3 | BIT2 | BIT1 | BIT0;
}
unsigned int get_version(void)
{
/*ENVIAR COMANDO*/
unsigned char m;
for(m=0;m<35;m++)
{
TXData =version_buff[m];
UCB0IE |= UCTXIE;
__bis_SR_register(LPM3_bits);
nfc_buff[m] = RXData ;
}
return 1;
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_B0_VECTOR
__interrupt void USCI_B0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_B0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCB0IV,USCI_SPI_UCTXIFG))
{
case USCI_NONE: break;
case USCI_SPI_UCRXIFG:
RXData = UCB0RXBUF;
UCB0IFG &= ~UCRXIFG;
__bic_SR_register_on_exit(LPM3_bits);
break;
case USCI_SPI_UCTXIFG:
UCB0TXBUF = TXData;
UCB0IE &= ~UCTXIE;
UCB0IE |= UCRXIE;
break;
default: break;
}
}
void PIN_config(void)
{
P1DIR|=0xF7; // Registro para indicar si el pin del puerto 2 es entrada o salida. 0=entrada 1=salida.
P1SEL0 |= BIT3 | BIT2 | BIT1 | BIT0;
P1REN |= 0x08;
P1OUT |= 0x08;
}