Hi Ralph, I have made the changes you have mentioned and also the changes below, now I'm able to detect the nfc tags but unable to read them. main.c void main(void) { //uint8_t ui8VLOCalibCount; // TODO: Remove LED2 Jumper on G2 LaunchPad if using it, otherwise SPI will not work. // Stop the Watchdog timer, WDTCTL = WDTPW + WDTHOLD; MCU_initClock(0); // Set DCO MCU_delayMillisecond(10); // Calibrate VLO //MCU_calculateVLOFreq(); // Set the SPI SS high SLAVE_SELECT_PORT_SET; SLAVE_SELECT_HIGH; // Four millisecond delay between bringing SS high and then EN high per TRF7970A Datasheet MCU_delayMillisecond(4); // Set TRF Enable Pin high TRF_ENABLE_SET; TRF_ENABLE; // Wait until TRF system clock started MCU_delayMillisecond(5); // Set up TRF initial settings TRF79xxA_initialSettings(); TRF79xxA_setTrfPowerSetting(TRF79xxA_3V_FULL_POWER); MCU_initClock(1); // Switching from DCO to external clock MCU_delayMillisecond(10); SPI_usciSet(); // Re-configure the USART with this external clock // Initialize all enabled technology layers NFC_init(); // Enable global interrupts __bis_SR_register(GIE); // Enable IRQ Pin IRQ_ON; while(1) { // Poll for NFC tags NFC_findTag(); /*ui8VLOCalibCount++; if (ui8VLOCalibCount == 25) { // Calibrate VLO MCU_calculateVLOFreq(); // Reset Calibration Counter ui8VLOCalibCount = 0; }*/ } } mcu.c void MCU_initClock (uint8_t mode) { uint8_t ii1 = 0; if(mode == 0) { // select DCO to 8MHz if (CALBC1_8MHZ==0xFF) // If calibration constant erased { while(1); // do not load, trap CPU!! } // Follow recommended flow. First, clear all DCOx and MODx bits. // Then apply new RSELx values. Finally, apply new DCOx and MODx bit // values. DCOCTL = 0x00; BCSCTL1 = CALBC1_8MHZ; DCOCTL = CALDCO_8MHZ; __delay_cycles(1000); return; } else { BCSCTL1 |= XTS + XT2OFF; // ACLK = LFXT1 HF XTAL BCSCTL3 |= LFXT1S1; // 3 – 16MHz crystal or resonator // the TRF796x sys_clk pin works as ocillator // it is set to 6.78 MHz (= 13.56 MHz / 2) in Trf797xInitialSettings() // turn external oscillator on do { IFG1 &= ~OFIFG; // Clear OSCFault flag for (ii1 = 0xFF; ii1 > 0; ii1--) // Time delay for flag to set { } } while ((IFG1 & OFIFG) == OFIFG); // OSCFault flag still set? BCSCTL2 |= SELM1 + SELM0 + SELS; // MCLK = SMCLK = HF LFXT1 (safe) return; } } #define COUNTER_VALUE TACCR0 //counter register #define START_COUNTER TACTL |= MC1 //start counter in up mode #define STOP_COUNTER TACTL &= ~(MC0 + MC1) //stops the counter #define RESET_COUNTER TACTL |= TACLR //Resets and stops counter. #define DELAY_1ms 6780 // Used for McuDelayMillisecond #define COUNT_1ms 847 void MCU_setCounter(uint16_t ui16mSecTimeout) { TACTL |= TACLR; TACTL &= ~TACLR; // reset the timerA TACTL |= TASSEL0 + ID1 + ID0; // ACLK, div 8, interrupt enable, timer stoped TAR = 0x0000; TACCTL0 |= CCIE; // compare interrupt enable COUNTER_VALUE = COUNT_1ms * ui16mSecTimeout; TACTL |= MC1; } #pragma vector=TIMERA0_VECTOR __interrupt void Msp430f23x0TimerAHandler(void) { TRF79xxA_timerHandler(); }
↧