Part Number: MSP432P4111
Tool/software: Code Composer Studio
HI,
I am working on the project integrating MSP432p4111 with BQ27441 while I found a HAL program for it and made it work I tried to shift it to another system where I got "compiler issue" and "path not found" issues, so I created the same project with the same files removing from the directory and including it in the project itself now I am getting
Description Resource Path Location Type
unresolved symbol CS_setDCOCenteredFrequency, first referenced in ./HAL_UART.obj battery C/C++ Problem
/* --COPYRIGHT--,BSD
* Copyright (c) 2015, 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--*/
//****************************************************************************
//
// HAL_I2C.c - Hardware abstraction layer for I2C with MSP432P401R
//
//****************************************************************************
#include <driverlib.h>
#include <HAL_I2C.h>
/* I2C Master Configuration Parameter */
/*
const eUSCI_I2C_MasterConfig i2cConfig =
{
EUSCI_B_I2C_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
48000000, // SMCLK = 3MHz
EUSCI_B_I2C_SET_DATA_RATE_400KBPS, // Desired I2C Clock of 400khz
0, // No byte counter threshold
EUSCI_B_I2C_NO_AUTO_STOP // No Autostop
};
*/
const eUSCI_I2C_MasterConfig i2cConfig =
{
EUSCI_B_I2C_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
3000000, // SMCLK = 3MHz (default)
EUSCI_B_I2C_SET_DATA_RATE_100KBPS, // Desired I2C Clock of 100khz
0, // No byte counter threshold
EUSCI_B_I2C_NO_AUTO_STOP // No Autostop
};
void I2C_initGPIO()
{
/* Select I2C function for I2C_SCL(P6.5) & I2C_SDA(P6.4) */
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6,
GPIO_PIN6 + GPIO_PIN7, GPIO_SECONDARY_MODULE_FUNCTION);
}
/***************************************************************************//**
* @brief Configures I2C
* @param none
* @return none
******************************************************************************/
//void I2C_init(void)
//{
/* Initialize USCI_B0 and I2C Master to communicate with slave devices*/
//I2C_initMaster(EUSCI_B1_BASE, &i2cConfig);
/* Disable I2C module to make changes */
// I2C_disableModule(EUSCI_B1_BASE);
/* Enable I2C Module to start operations */
//I2C_enableModule(EUSCI_B1_BASE);
// return;
//}
void I2C_init(void)
{
MAP_I2C_initMaster(EUSCI_B3_BASE, &i2cConfig);
EUSCI_B_I2C_setSlaveAddress(EUSCI_B3_BASE,
0x55);
MAP_I2C_disableModule(EUSCI_B3_BASE);
MAP_I2C_enableModule(EUSCI_B3_BASE);
// MAP_I2C_enableInterrupt(EUSCI_B3_BASE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
// MAP_I2C_enableInterrupt(EUSCI_B3_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);
}
/***************************************************************************//**
* @brief Writes data to the sensor
* @param pointer Address of register you want to modify
* @param writeByte Data to be written to the specified register
* @return none
******************************************************************************/
bool I2C_write8 (unsigned char pointer, unsigned char writeByte, unsigned int timeout)
{
/* Set master to transmit mode PL */
MAP_I2C_setMode(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_MODE);
/* Clear any existing interrupt flag PL */
MAP_I2C_clearInterruptFlag(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
/* Initiate start and send first character */
if (!MAP_I2C_masterSendMultiByteStartWithTimeout(EUSCI_B3_BASE,
pointer, timeout))
return 0;
if (!MAP_I2C_masterSendMultiByteFinishWithTimeout(EUSCI_B3_BASE,
writeByte, timeout))
return 0;
return 1;
}
/***************************************************************************//**
* @brief Writes data to the sensor
* @param pointer Address of register you want to modify
* @param writeWord Data to be written to the specified register
* @return none
******************************************************************************/
bool I2C_write16 (unsigned char pointer, unsigned short writeWord, unsigned int timeout)
{
/* Set master to transmit mode PL */
MAP_I2C_setMode(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_MODE);
/* Clear any existing interrupt flag PL */
MAP_I2C_clearInterruptFlag(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
/* Initiate start and send first character */
if (!MAP_I2C_masterSendMultiByteStartWithTimeout(EUSCI_B3_BASE,
pointer, timeout))
return 0;
/* Send the MSB of writeByte to SENSOR */
if (!MAP_I2C_masterSendMultiByteNextWithTimeout(EUSCI_B3_BASE,
(unsigned char)(writeWord&0xFF), timeout))
return 0;
if (!MAP_I2C_masterSendMultiByteFinishWithTimeout(EUSCI_B3_BASE,(unsigned char)(writeWord>>8), timeout))
return 0;
return 1;
}
/***************************************************************************//**
* @brief Reads data from the sensor
* @param pointer Address of register to read from
* @return Register contents
******************************************************************************/
bool I2C_read8(unsigned char pointer, char * result, unsigned int timeout)
{
volatile int val = 0;
volatile int valScratch = 0;
/* Set master to transmit mode PL */
MAP_I2C_setMode(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_MODE);
/* Clear any existing interrupt flag PL */
MAP_I2C_clearInterruptFlag(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
/* Initiate start and send first character */
if (!MAP_I2C_masterSendSingleByteWithTimeout(EUSCI_B3_BASE,
pointer, timeout))
return 0;
/*
* Generate Start condition and set it to receive mode.
* This sends out the slave address and continues to read
* until you issue a STOP
*/
// I2C_masterReceiveStart(EUSCI_B1_BASE);
//
// /* Read from I2C RX register */
// if(!I2C_masterReceiveMultiByteFinishWithTimeout(EUSCI_B1_BASE, &val, timeout))
// return 0;
//
// /* Return temperature value */
// *result = val;
*result = MAP_I2C_masterReceiveSingleByte(EUSCI_B3_BASE);
return 1;
}
/***************************************************************************//**
* @brief Reads data from the sensor
* @param pointer Address of register to read from
* @return Register contents
******************************************************************************/
bool I2C_read16(unsigned char pointer, short * result, unsigned int timeout)
{
uint8_t val = 0;
uint8_t valScratch = 0;
short r = 0;
/* Set master to transmit mode PL */
MAP_I2C_setMode(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_MODE);
/* Clear any existing interrupt flag PL */
MAP_I2C_clearInterruptFlag(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
/* Initiate start and send first character */
if (!MAP_I2C_masterSendSingleByteWithTimeout(EUSCI_B3_BASE, pointer, timeout))
return 0;
/*
* Generate Start condition and set it to receive mode.
* This sends out the slave address and continues to read
* until you issue a STOP
*/
MAP_I2C_masterReceiveStart(EUSCI_B3_BASE);
/* Wait for RX buffer to fill */
while(!(MAP_I2C_getInterruptStatus(EUSCI_B3_BASE,EUSCI_B_I2C_RECEIVE_INTERRUPT0)));
/* Read from I2C RX register */
valScratch = MAP_I2C_masterReceiveMultiByteNext(EUSCI_B3_BASE);
/* Receive second byte then send STOP condition */
if (!MAP_I2C_masterReceiveMultiByteFinishWithTimeout(EUSCI_B3_BASE, &val, timeout))
return 0;
/* Shift val to top MSB */
r = (val << 8);
/* Read from I2C RX Register and write to LSB of r */
r |= valScratch;
/* Return temperature value */
*result = r;
return 1;
}
void I2C_setslave(unsigned short slaveAdr)
{
/* Specify slave address for I2C */
EUSCI_B_I2C_setSlaveAddress(EUSCI_B3_BASE,
slaveAdr);
/* Enable and clear the interrupt flag */
EUSCI_B_I2C_clearInterruptFlag(EUSCI_B3_BASE,
EUSCI_B_I2C_TRANSMIT_INTERRUPT0 + EUSCI_B_I2C_RECEIVE_INTERRUPT0);
return;
}
/* --COPYRIGHT--,BSD
* Copyright (c) 2015, 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--*/
//****************************************************************************
//
// HAL_UART.c - Hardware abstraction layer for UART with MSP432P401R
//
//****************************************************************************
#include <HAL_UART.h>
#include "driverlib.h"
#include <msp.h>
//GPRS
/* UART Configuration Parameter. These are the configuration parameters to
* make the eUSCI A UART module to operate with a 115200 baud rate. These
* values were calculated using the online calculator that TI provides
* at:
*http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
*/
const eUSCI_UART_ConfigV1 uartConfig =
{
EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
78, // BRDIV = 78
2, // UCxBRF = 2
0, // UCxBRS = 0
EUSCI_A_UART_NO_PARITY, // No Parity
EUSCI_A_UART_LSB_FIRST, // LSB First
EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
EUSCI_A_UART_MODE, // UART mode
EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION, // Oversampling
EUSCI_A_UART_8_BIT_LEN // 8 bit data length
};
/* Initializes Backchannel UART GPIO */
void UART_initGPIO()
{
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
}
/***************************************************************************//**
* @brief Configures UART
* @param none
* @return none
******************************************************************************/
void UART_init(void)
{
CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);
MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig);
/* Enable UART module */
MAP_UART_enableModule(EUSCI_A0_BASE);
}
/* Transmits String over UART */
void UART_transmitString( char *pStr )
{
while( *pStr )
{
// comented for testing
MAP_UART_transmitData(EUSCI_A0_BASE, *pStr);
pStr++;
}
}
/* Transmits String over UART Debug*/
void serialTx0( char *pStr )
{
while( *pStr )
{
MAP_UART_transmitData(EUSCI_A0_BASE, *pStr );
pStr++;
}
}
