This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2633: Clock selection for SPI interface using MSP430FR2633

Part Number: MSP430FR2633
Other Parts Discussed in Thread: MSP430FR2533, UNIFLASH

Hello,

I am developing 32 keys capacitive touch PCB using MSP430FR2633.

In this am trying to implement SPI interface, for that I have done following initialization in CCS;

//Initialize as Master
EUSCI_A_SPI_initMasterParam param = {0};
param.selectClockSource = EUSCI_A_SPI_CLOCKSOURCE_SMCLK;

param.clockSourceFrequency = CS_getSMCLK();
param.desiredSpiClock = 500000;
param.msbFirst = EUSCI_A_SPI_MSB_FIRST;
param.clockPhase = EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
param.clockPolarity = EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW;
param.spiMode = EUSCI_A_SPI_3PIN;
EUSCI_A_SPI_initMaster(EUSCI_A1_BASE, &param);

Am not using external crystal or any other external clock source, so instead of  "CS_getSMCLK() ", which clock function shall I use?

  • What's wrong with using CS_getSMCLK()?

  • The root clock source of SMCLK can be  REFO. It can work without external crystal.

  • Isn't this function defined for external crystal oscillator?

    Am not using external crystal oscillator, am using internal clock, so which function I should use for SPI communication in the SPI Initialize as Master code? 

  •  

    Yes SMCLK will work without external crystal oscillator, for that the function to get SMCLK is CS_turnOnSMCLK();  also this function  returns nothing

    But for SPI protocol communication, which I want to implement, I referred TI the sample code "eusci_a_spi_ex1_master", in that the following statements are there:

    //Initialize Master
    EUSCI_A_SPI_initMasterParam param = {0};
    param.selectClockSource = EUSCI_A_SPI_CLOCKSOURCE_SMCLK;
    param.clockSourceFrequency = CS_getSMCLK(); 
    param.desiredSpiClock = 500000;
    param.msbFirst = EUSCI_A_SPI_MSB_FIRST;
    param.clockPhase = EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
    param.clockPolarity = EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW;
    param.spiMode = EUSCI_A_SPI_3PIN;
    EUSCI_A_SPI_initMaster(EUSCI_A1_BASE, &param);

    here the function CS_getSMCLK();  returns uint32_t variable value, so I cannot use CS_turnOnSMCLK(); instead of CS_getSMCLK();

  • CS_getSMCLK() returns a number, specifically the clock frequency that SMCLK is currently running at (probably 1000000UL meaning 1MHz). This is exactly what is required for the clockSourceFrequency field. You could also just write param.clockSourceFrequency=1000000UL, but then you'd have to remember to change it if you change the SMCLK speed.

    SMCLK starts running automatically, from the DCO (no crystal) at about 1MHz when the system starts. You don't need to start it.

  • ok, thank you for solution, I'll try and let you know its result.

  • Hi, Bruce,

    Thank you for helping to answer the question.

    Eason

  • Hi, am getting clock signal now but still not able establish SPI communication between MSP430FR2533 and RFID MFRC522. 

    My coding files are as below:

    /**	
     * |----------------------------------------------------------------------
     * | Copyright (C) Tilen Majerle, 2014
     * | 
     * | This program is free software: you can redistribute it and/or modify
     * | it under the terms of the GNU General Public License as published by
     * | the Free Software Foundation, either version 3 of the License, or
     * | any later version.
     * |  
     * | This program is distributed in the hope that it will be useful,
     * | but WITHOUT ANY WARRANTY; without even the implied warranty of
     * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * | GNU General Public License for more details.
     * | 
     * | You should have received a copy of the GNU General Public License
     * | along with this program.  If not, see <http://www.gnu.org/licenses/>.
     * |----------------------------------------------------------------------
     */
    #include "tm_stm32f4_mfrc522.h"
    #include "msp430fr2633.h"
    
    
    extern void EUSCI_A_SPI_transmitData(uint16_t baseAddress, uint8_t transmitData);
    extern uint8_t EUSCI_A_SPI_receiveData(uint16_t baseAddress);
    			 
    
    void TM_MFRC522_Init(void)
    {
    	
    	TM_MFRC522_Reset();
      
    	GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN0);			/* CS PIN */
    	 
    	TM_MFRC522_WriteRegister(MFRC522_REG_T_MODE, 0x8D);
    	TM_MFRC522_WriteRegister(MFRC522_REG_T_PRESCALER, 0x3E);
    	TM_MFRC522_WriteRegister(MFRC522_REG_T_RELOAD_L, 30);           
    	TM_MFRC522_WriteRegister(MFRC522_REG_T_RELOAD_H, 0);
    
    	/* 48dB gain */
    	TM_MFRC522_WriteRegister(MFRC522_REG_RF_CFG, 0x70);
    	
    	TM_MFRC522_WriteRegister(MFRC522_REG_TX_AUTO, 0x40);
    	TM_MFRC522_WriteRegister(MFRC522_REG_MODE, 0x3D);
    
    	TM_MFRC522_AntennaOn();		//Open the antenna
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Check(uint8_t* id)
    {
    	TM_MFRC522_Status_t status;
    	//Find cards, return card type
    	status = TM_MFRC522_Request(PICC_REQIDL, id);	
    	if (status == MI_OK)
      {
    		//Card detected
    		//Anti-collision, return card serial number 4 bytes
    		status = TM_MFRC522_Anticoll(id);
    
      }
    		return status;
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Compare(uint8_t* CardID, uint8_t* CompareID)
    {
    	uint8_t i;
    	for (i = 0; i < 5; i++) {
    		if (CardID[i] != CompareID[i]) {
    			return MI_ERR;
    		}
    	}
    	return MI_OK;
    }
    
    
    
    void TM_MFRC522_WriteRegister(uint8_t addr, uint8_t val)
    {
    	uint8_t buffer[5]="";
    	
    
    	GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN0);			/* CS PIN */
    	
    	buffer[0] = (addr << 1) & 0x7E;
    	buffer[1] = val;
    	
    	EUSCI_A_SPI_transmitData(EUSCI_A0_BASE, 12);
    	
    
    	GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN0);			/* CS PIN */
    	__delay_cycles(100);
    }
    
    uint8_t TM_MFRC522_ReadRegister(uint8_t addr)
    {
    	uint8_t i, buffer[5];
    	
    
    	GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN0);			/* CS PIN */
    	 __delay_cycles(100);
    	
    	buffer[0] = ((addr << 1) & 0x7E) | 0x80 ;
        buffer[1] = 0;
    	
        for(i=0;i<2;i++)
    	  EUSCI_A_SPI_transmitData(EUSCI_A0_BASE, buffer[i]);
    									 
    	buffer[0] = MFRC522_DUMMY;
    	buffer[1] = MFRC522_DUMMY;
    	
    
        buffer[1] = EUSCI_A_SPI_receiveData(EUSCI_A0_BASE);
    		
    
    	GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN0);			/* CS PIN */
    	__delay_cycles(100);
    	return buffer[1];	
    }
    
    void TM_MFRC522_SetBitMask(uint8_t reg, uint8_t mask)
    {
    	TM_MFRC522_WriteRegister(reg, TM_MFRC522_ReadRegister(reg) | mask);
    }
    
    void TM_MFRC522_ClearBitMask(uint8_t reg, uint8_t mask)
    {
    	TM_MFRC522_WriteRegister(reg, TM_MFRC522_ReadRegister(reg) & (~mask));
    } 
    
    void TM_MFRC522_AntennaOn(void)
    {
    	uint8_t temp;
    
    	temp = TM_MFRC522_ReadRegister(MFRC522_REG_TX_CONTROL);
    	
    	if (!(temp & 0x03))
    	{
    		TM_MFRC522_SetBitMask(MFRC522_REG_TX_CONTROL, 0x03);
    	}
    }
    
    void TM_MFRC522_AntennaOff(void)
    {
    	TM_MFRC522_ClearBitMask(MFRC522_REG_TX_CONTROL, 0x03);
    }
    
    void TM_MFRC522_Reset(void)
    {
    	TM_MFRC522_WriteRegister(MFRC522_REG_COMMAND, PCD_RESETPHASE);
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Request(uint8_t reqMode, uint8_t* TagType)
    {
    	TM_MFRC522_Status_t status;  
    	uint16_t backBits;			//The received data bits
    
    	TM_MFRC522_WriteRegister(MFRC522_REG_BIT_FRAMING, 0x07);		//TxLastBists = BitFramingReg[2..0]	???
    
    	TagType[0] = reqMode;
    	status = TM_MFRC522_ToCard(PCD_TRANSCEIVE, TagType, 1, TagType, &backBits);
    
    	if ((status != MI_OK) || (backBits != 0x10))
    	{    
    		status = MI_ERR;
    	}
    
    	return status;
    }
    
    TM_MFRC522_Status_t TM_MFRC522_ToCard(uint8_t command, uint8_t* sendData, uint8_t sendLen, uint8_t* backData, uint16_t* backLen) 
    {
    	TM_MFRC522_Status_t status = MI_ERR;
    	uint8_t irqEn = 0x00;
    	uint8_t waitIRq = 0x00;
    	uint8_t lastBits;
    	uint8_t n;
    	uint16_t i;
    
    	switch (command)
    	{
    		case PCD_AUTHENT: 
    		{
    			irqEn = 0x12;
    			waitIRq = 0x10;
    			break;
    		}
    		case PCD_TRANSCEIVE: 
    		{
    			irqEn = 0x77;
    			waitIRq = 0x30;
    			break;
    		}
    		default:
    			break;
    	}
    
    	TM_MFRC522_WriteRegister(MFRC522_REG_COMM_IE_N, irqEn | 0x80);
    	TM_MFRC522_ClearBitMask(MFRC522_REG_COMM_IRQ, 0x80);
    	TM_MFRC522_SetBitMask(MFRC522_REG_FIFO_LEVEL, 0x80);
    
    	TM_MFRC522_WriteRegister(MFRC522_REG_COMMAND, PCD_IDLE);
    
    	//Writing data to the FIFO
    	for (i = 0; i < sendLen; i++)
    	{   
    		TM_MFRC522_WriteRegister(MFRC522_REG_FIFO_DATA, sendData[i]);    
    	}
    
    	//Execute the command
    	TM_MFRC522_WriteRegister(MFRC522_REG_COMMAND, command);
    	
    	if (command == PCD_TRANSCEIVE)
    	{    
    		TM_MFRC522_SetBitMask(MFRC522_REG_BIT_FRAMING, 0x80);		//StartSend=1,transmission of data starts  
    	}   
    
    	//Waiting to receive data to complete
    	i = 25;	//i according to the clock frequency adjustment, the operator M1 card maximum waiting time 25ms???
    	do 
    	{
    		//CommIrqReg[7..0]
    		//Set1 TxIRq RxIRq IdleIRq HiAlerIRq LoAlertIRq ErrIRq TimerIRq
    		n = TM_MFRC522_ReadRegister(MFRC522_REG_COMM_IRQ);
    		i--;
    	} while ((i!=0) && !(n&0x01) && !(n&waitIRq));
    
    	TM_MFRC522_ClearBitMask(MFRC522_REG_BIT_FRAMING, 0x80);			//StartSend=0
    
    	if (i != 0)  
    	{
    		if (!(TM_MFRC522_ReadRegister(MFRC522_REG_ERROR) & 0x1B)) 
    		{
    			status = MI_OK;
    			if (n & irqEn & 0x01)
    			{   
    				status = MI_NOTAGERR;			
    			}
    
    			if (command == PCD_TRANSCEIVE)
    			{
    				n = TM_MFRC522_ReadRegister(MFRC522_REG_FIFO_LEVEL);
    				lastBits = TM_MFRC522_ReadRegister(MFRC522_REG_CONTROL) & 0x07;
    				if (lastBits)
    				{   
    					*backLen = (n - 1) * 8 + lastBits;   
    				}
    				else
    				{   
    					*backLen = n * 8;   
    				}
    
    				if (n == 0)
    				{   
    					n = 1;    
    				}
    				if (n > MFRC522_MAX_LEN)
    				{   
    					n = MFRC522_MAX_LEN;   
    				}
    
    				//Reading the received data in FIFO
    				for (i = 0; i < n; i++) 
    				{   
    					backData[i] = TM_MFRC522_ReadRegister(MFRC522_REG_FIFO_DATA);    
    				}
    			}
    		} 
    		else 
    		{   
    			status = MI_ERR;  
    		}
    	}
    
    	return status;
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Anticoll(uint8_t* serNum)
    {
    	TM_MFRC522_Status_t status;
    	uint8_t i;
    	uint8_t serNumCheck = 0;
    	uint16_t unLen;
    
    	TM_MFRC522_WriteRegister(MFRC522_REG_BIT_FRAMING, 0x00);		//TxLastBists = BitFramingReg[2..0]
    
    	serNum[0] = PICC_ANTICOLL;
    	serNum[1] = 0x20;
    	status = TM_MFRC522_ToCard(PCD_TRANSCEIVE, serNum, 2, serNum, &unLen);
    
    	if (status == MI_OK)
    	{
    		//Check card serial number
    		for (i = 0; i < 4; i++)
    		{   
    			serNumCheck ^= serNum[i];
    		}
    		if (serNumCheck != serNum[i]) 
    		{   
    			status = MI_ERR;    
    		}
    	}
    	return status;
    } 
    
    void TM_MFRC522_CalculateCRC(uint8_t*  pIndata, uint8_t len, uint8_t* pOutData)
    {
    	uint8_t i, n;
    
    	TM_MFRC522_ClearBitMask(MFRC522_REG_DIV_IRQ, 0x04);			//CRCIrq = 0
    	TM_MFRC522_SetBitMask(MFRC522_REG_FIFO_LEVEL, 0x80);			//Clear the FIFO pointer
    	//Write_MFRC522(CommandReg, PCD_IDLE);
    
    	//Writing data to the FIFO	
    	for (i = 0; i < len; i++)
    	{   
    		TM_MFRC522_WriteRegister(MFRC522_REG_FIFO_DATA, *(pIndata+i));   
    	}
    	TM_MFRC522_WriteRegister(MFRC522_REG_COMMAND, PCD_CALCCRC);
    
    	//Wait CRC calculation is complete
    	i = 0xFF;
    	do
    	{
    		n = TM_MFRC522_ReadRegister(MFRC522_REG_DIV_IRQ);
    		i--;
    	} while ((i!=0) && !(n&0x04));			//CRCIrq = 1
    
    	//Read CRC calculation result
    	pOutData[0] = TM_MFRC522_ReadRegister(MFRC522_REG_CRC_RESULT_L);
    	pOutData[1] = TM_MFRC522_ReadRegister(MFRC522_REG_CRC_RESULT_M);
    }
    
    uint8_t TM_MFRC522_SelectTag(uint8_t* serNum)
    {
    	uint8_t i;
    	TM_MFRC522_Status_t status;
    	uint8_t size;
    	uint16_t recvBits;
    	uint8_t buffer[9]; 
    
    	buffer[0] = PICC_SElECTTAG;
    	buffer[1] = 0x70;
    	for (i = 0; i < 5; i++)
    	{
    		buffer[i+2] = *(serNum+i);
    	}
    	TM_MFRC522_CalculateCRC(buffer, 7, &buffer[7]);		//??
    	status = TM_MFRC522_ToCard(PCD_TRANSCEIVE, buffer, 9, buffer, &recvBits);
    
    	if ((status == MI_OK) && (recvBits == 0x18))
    	{   
    		size = buffer[0]; 
    	}
    	else
    	{   
    		size = 0;    
    	}
    
    	return size;
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Auth(uint8_t authMode, uint8_t BlockAddr, uint8_t* Sectorkey, uint8_t* serNum)
    {
    	TM_MFRC522_Status_t status;
    	uint16_t recvBits;
    	uint8_t i;
    	uint8_t buff[12]; 
    
    	//Verify the command block address + sector + password + card serial number
    	buff[0] = authMode;
    	buff[1] = BlockAddr;
    	for (i = 0; i < 6; i++) 
    	{    
    		buff[i+2] = *(Sectorkey+i);   
    	}
    	for (i=0; i<4; i++)
    	{    
    		buff[i+8] = *(serNum+i);   
    	}
    	
      	status = TM_MFRC522_ToCard(PCD_AUTHENT, buff, 12, buff, &recvBits);
    	
    	if ((status != MI_OK) || (!(TM_MFRC522_ReadRegister(MFRC522_REG_STATUS2) & 0x08)))
    	{   
    		status = MI_ERR;   
    	}
    
    	return status;
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Read(uint8_t blockAddr, uint8_t* recvData)
    {
    	TM_MFRC522_Status_t status;
    	uint16_t unLen;
    
    	recvData[0] = PICC_READ;
    	recvData[1] = blockAddr;
    	TM_MFRC522_CalculateCRC(recvData,2, &recvData[2]);
    	status = TM_MFRC522_ToCard(PCD_TRANSCEIVE, recvData, 4, recvData, &unLen);
    
    	if ((status != MI_OK) || (unLen != 0x90))
    	{
    		status = MI_ERR;
    	}
    
    	return status;
    }
    
    TM_MFRC522_Status_t TM_MFRC522_Write(uint8_t blockAddr, uint8_t* writeData)
    {
    	TM_MFRC522_Status_t status;
    	uint16_t recvBits;
    	uint8_t i;
    	uint8_t buff[18]; 
    
    	buff[0] = PICC_WRITE;
    	buff[1] = blockAddr;
    	TM_MFRC522_CalculateCRC(buff, 2, &buff[2]);
    	status = TM_MFRC522_ToCard(PCD_TRANSCEIVE, buff, 4, buff, &recvBits);
    
    	if ((status != MI_OK) || (recvBits != 4) || ((buff[0] & 0x0F) != 0x0A))
    	{   
    		status = MI_ERR;   
    	}
    
    	if (status == MI_OK)
    	{
    		//Data to the FIFO write 16Byte
    		for (i = 0; i < 16; i++) 
    		{    
    			buff[i] = *(writeData+i);   
    		}
    		TM_MFRC522_CalculateCRC(buff, 16, &buff[16]);
    		status = TM_MFRC522_ToCard(PCD_TRANSCEIVE, buff, 18, buff, &recvBits);
    
    		if ((status != MI_OK) || (recvBits != 4) || ((buff[0] & 0x0F) != 0x0A))
    		{   
    			status = MI_ERR;   
    		}
    	}
    
    	return status;
    }
    
    void TM_MFRC522_Halt(void)
    {
    	uint16_t unLen;
    	uint8_t buff[4]; 
    
    	buff[0] = PICC_HALT;
    	buff[1] = 0;
    	TM_MFRC522_CalculateCRC(buff, 2, &buff[2]);
    
    	TM_MFRC522_ToCard(PCD_TRANSCEIVE, buff, 4, buff, &unLen);
    }
    
    

    eusci_a_spi.h

    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    //*****************************************************************************
    // Development main.c for MSP430FR2633, MSP430FR2533, MSP430FR2632, and
    // MSP430FR2532.
    //
    // This starter application initializes the CapTIvate touch library
    // for the touch panel specified by CAPT_UserConfig.c/.h via a call to
    // CAPT_appStart(), which initializes and calibrates all sensors in the
    // application, and starts the CapTIvate interval timer.
    //
    // Then, the capacitive touch interface is driven by calling the CapTIvate
    // application handler, CAPT_appHandler().  The application handler manages
    // whether the user interface (UI) is running in full active scan mode, or
    // in a low-power wake-on-proximity mode.
    //
    // The CapTIvate application handler will return true if proximity was
    // detected on any of the sensors in the application, which is used here
    // to control the state of LED2. LED1 is set while the background loop enters
    // the handler, and is cleared when the background loop leaves the handler.
    //
    // \version 1.81.00.07
    // Released on August 13, 2019
    //
    //*****************************************************************************
    
    #include <msp430.h>                      // Generic MSP430 Device Include
    #include "driverlib.h"                   // MSPWare Driver Library
    #include "captivate.h"                   // CapTIvate Touch Software Library
    #include "CAPT_App.h"                    // CapTIvate Application Code
    #include "CAPT_BSP.h"                    // CapTIvate EVM Board Support Package
    
    #include "LCD_20x4.h"
    #include "cs.h"
    #include "CAPTIVATE_PHONE_Demo.h"        // CAPTIVATE-PHONE PCB Demo
    #include "tm_stm32f4_mfrc522.h"
    
    #define CS_FLLREF                 0x08
    #define SELMS__REFOCLK           (0x0001)
    #define CS_REFOCLK_SELECT      SELMS__REFOCLK
    
    
    extern void Pin_Initialization(void);
    extern void TM_HD44780_InitPins(void);
    extern uint32_t CS_getMCLK(void);
    //extern TM_MFRC522_Status_t TM_MFRC522_Check(uint8_t* id);
    
    const uint8_t ui8LFOsc=CS_REFOCLK_SELECT;
    CS_initFLLParam fllParams = {0};
    uint16_t faultflags=0;
    uint16_t c=0,r=0;
    
    char LCD_Buff[21];
    uint8_t key=0xFF;
    uint8_t RFID[5];
    
    
    /*----------------  CAP 32 Code -----------------*/
    
    uint8_t RXData = 0;         /* Code Entered for SPI */
    uint8_t TXData = 0;         /* Code Entered for SPI */
    
    
    void main(void)
    {
    	//
    	// Initialize the MCU
    	// BSP_configureMCU() sets up the device IO and clocking
    	// The global interrupt enable is set to allow peripherals
    	// to wake the MCU.
    	//
    	WDTCTL = WDTPW | WDTHOLD;       // Stop watch dog timer
    
    
    	Pin_Initialization();
    
    	//
        // Initialize Clock Signals
        //
        CS_initClockSignal(CS_FLLREF, ui8LFOsc, CS_CLOCK_DIVIDER_1);
        CS_initClockSignal(CS_MCLK, CS_DCOCLKDIV_SELECT, CS_CLOCK_DIVIDER_1);
    
    
        //
        // Tune the DCO parameters
        //
        faultflags = CS_initFLLCalculateTrim((MCLK_FREQ/1000), FLL_RATIO, &fllParams);
        faultflags = CS_clearAllOscFlagsWithTimeout(1000);
    
        //BSP_configureMCU();
        __bis_SR_register(GIE);
    
        LCD_Init(16,2);
        LCD_Puts(0,0,"Start LCD54");
    
        Demo_init();
    
        //
        // Start the CapTIvate application
        //
        CAPT_appStart();
    
    	//
    	// Background Loop
    	//
    	while(1)
    	{
    	    CAPT_appHandler();
    	  //Demo_checkForValidTouch();
    	  //CAPT_appSleep();
    	    if(key != 0xFF)
    	    {
    	        memset(LCD_Buff,0x20,21);
    	        LCD_Buff[16]=0;
    
    	        LCD_Buff[c]=key;
    	        LCD_Puts(c, r, &LCD_Buff[c]);
    	        c++;
    	        if (c>0x0F)
    	        {
    	            c=0x00;
    	            r++;
    	        }
    	        if (r>1)
    	        {
    	            r=0x00;
    	        }
    	        key=0xFF;
    	    }
    
    
    
    	    //TM_MFRC522_Status_t TM_MFRC522_Check(RFID);
    
    	   TM_MFRC522_ReadRegister(0x37);
    	} // End background loop
    } // End main()
    

    Please suggest any correction.

  • What is your test case? How do you know you're not succeeding?

    ---

    > EUSCI_A_SPI_transmitData(EUSCI_A0_BASE, 12);

    This looks somewhat odd. Did you mean something like (in a loop):

    > EUSCI_A_SPI_transmitData(EUSCI_A0_BASE, buffer[i]);

    ---

    > buffer[1] = EUSCI_A_SPI_receiveData(EUSCI_A0_BASE);

    You need to wait for the SPI to finish here. Try preceding this line with something like:

    > EUSCI_A_SPI_isBusy(EUSCI_A0_BASE);

  • ok will try this,

    or can I try 

    > __delay_cycles(100);

    instead of  

    > EUSCI_A_SPI_isBusy(EUSCI_A0_BASE);

  • Apart from this I am facing one more problem, my MSP430 USB debug Interface, gives following error:

    MSP430: File Loader: Verification failed: Values at address 0x0D106 do not match Please verify target memory and memory map.
    MSP430: GEL: File: C:\Users\admin\workspace_v10\Cap_32_30_5\Debug\Cap_32_30_5.out: a data verification error occurred, file load failed.

    after 5-6 random efforts the program gets dubugged  automatically without making any changes in code.

  • Yes you can. But it is not so robust. 

    Try to use no verification, CCS will first read out the code from device and compare it with the existing project in the workspace. Maybe the code in your MCU has been changed. 

  • Hi Eason,

    I tried this solution suggested by you but its not working.

    I also tried the solution suggested in the forum on following link, but it is not working as well.

    https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/648591?CCS-MSP430FR5969-File-Loader-Data-verification-failed-Please-verify-target-memory-and-memory-map-

    So is it possible that there is problem on hardware side?

  • or using UNIFLASH will help?

  • Hi,

    I checked UNIFLASH,

    all the options of UNIFLASH are present in CCS, so I guess UNIFLASH will hardly be of any use.

    Waiting for response, not able to develop further, as got stuck at this point, due to memory getting into Write Protection mode.

    Thank you.

  • Hi,

    You can try to use uniflash to erase the full main memory and information memory.

**Attention** This is a public forum