Other Parts Discussed in Thread: TM4C1233H6PM
Hey
I have been trying to resolve and issue for the passed week, with some code relating to I2C. Previously I have been running through the lab tutorials on the wiki i.e. making the LED's blink etc, just familiarising myself with the Tiva platform.
I know how to set up a basic skeleton new CCS project for the Tiva,using TM4C123G LaunchPad Pad Workshop Workbook from Lab 2 and add lib. The launchpad is a stellaris with MCU LM4F120H5QR, so I select the equivalent in Tivaware which is TM4C1233H6PM.
SO armed with this basic knowledge I am attempting to use the I2C to communicate with a pressure sensor, I have managed to do this already with the Arduino (blasphemy I here cry). However when I copied the code into my new project, I get a host errors. The code is from following link : http://sanjosetech.blogspot.dk/2013/04/stellaris-launchpad-working-i2c-code.html
I also had pasted the code here:
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_uart.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_i2c.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "driverlib/i2c.h"
#include "utils/ustdlib.h"
#include "utils/uartstdio.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define I2C_SLAVE_ADDRESS 0x60
/*****************************************************************************/
/* This function returns:
* I2C_MASTER_ERR_NONE, I2C_MASTER_ERR_ADDR_ACK, I2C_MASTER_ERR_DATA_ACK, or
* I2C_MASTER_ERR_ARB_LOST.
*/
static unsigned long WaitI2CDone( unsigned int long ulBase){
// Wait until done transmitting
while( I2CMasterBusy(I2C3_MASTER_BASE));
// Return I2C error code
return I2CMasterErr( I2C3_MASTER_BASE);
}
static void SetupI2C(){
/***
* Shared Pin Setting
*/
// You need to set the shared pins as input.
GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6 | GPIO_PIN_7);
// Change the pad configuration to WPU
GPIOPadConfigSet( GPIO_PORTB_BASE, GPIO_PIN_6 | GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD_WPU);
/***
* I2C Setting
*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0); // special I2CSCL treatment for M4F devices
GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
GPIOPinConfigure(GPIO_PD0_I2C3SCL);
GPIOPinConfigure(GPIO_PD1_I2C3SDA);
SysCtlPeripheralEnable( SYSCTL_PERIPH_I2C3);
I2CMasterInitExpClk( I2C3_MASTER_BASE, SysCtlClockGet(), false);
SysCtlDelay(10000);
}
int main(void) {
uint8_t data = 0;
int16_t i2c_err = I2C_MASTER_ERR_NONE;
//
// Setup the system clock to run at 50 Mhz from PLL with crystal reference
//
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
SYSCTL_OSC_MAIN);
SysCtlDelay(10000);
SetupI2C();
/** Send register address.
*/
I2CMasterSlaveAddrSet( I2C3_MASTER_BASE, I2C_SLAVE_ADDRESS, false); // false = write, true = read
// Set register address of AK8963
I2CMasterDataPut( I2C3_MASTER_BASE, 0x00);
// Start sending data
I2CMasterControl( I2C3_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
WaitI2CDone( I2C3_MASTER_BASE);
/** Set read mode.
*/
I2CMasterSlaveAddrSet( I2C3_MASTER_BASE, I2C_SLAVE_ADDRESS, true); // false = write, true = read
/** Single Read
*/
I2CMasterControl( I2C3_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
if( (i2c_err = WaitI2CDone( I2C3_MASTER_BASE)))
data = 0xff;
else
data = I2CMasterDataGet(I2C3_MASTER_BASE);
return 0;
}
I got the following Errors
I have also included a screen shot showing the complier and linker properties, just so you see what I have added.
Thank you in advance,
Angu's