Technical Support
On-Line Manuals
µVision User's Guide
Hi, I am working on MCB2300 (LPC2378) and I am using Keil uVision4. In my code I need to give some inputs to the code using serial window. Please let me know how to input some text using serial window. Previous versions of the tools used a Serial Number and an add-on disk for licensing - this Serial Number will not work in the newer version of the tools. One person may install the tools and use their PSN to get LICs for up to 2 of their computers. You may unlicense a computer to move the license to another computer.
About µVisionUser InterfaceCreating ApplicationsDebuggingStart DebuggingStart Energy Measurement without DebugApplication Program ExecutionDebug Windows and DialogsBreakpoints WindowCall Stack and Locals WindowCode CoverageCommand WindowComponent ViewerDisassembly WindowEditor WindowEvent RecorderSetup Event RecorderEvent Recorder WindowEvents FilteringEvent Statistics WindowPost-mortem AnalysisEvent ViewerExecution ProfilerInstruction Trace WindowSystem AnalyzerUsage tipsSave System Analyzer ContentsStatisticsRestrictionsLogic AnalyzerSetupSetup in DetailRestrictionsCortex-M Trace ConfigurationMemory MapMemory WindowPerformance AnalyzerRegisters WindowSerial WindowDebug (printf) ViewerSymbols WindowSystem ViewerAdding System Viewer WindowsSystem and Thread ViewerThread StatesToolboxTrace Data WindowTrace NavigationTrace ExceptionsEvent CountersULINKplus WindowWatch WindowCore PeripheralsCortex-M0 and Cortex-M0+Nested Vector Interrupt ControllerSystem Control and ConfigurationSystem Tick TimerFault Reports (Cortex-M0+ only)Cortex-M3, Cortex-M4, and Cortex-M7Nested Vector Interrupt ControllerSystem Control and ConfigurationSystem Tick TimerFault ReportsMemory Protection UnitCortex-M23/M33/M35P and Cortex-M55Nested Vector Interrupt ControllerSystem Control and ConfigurationSystem Tick TimerFault ReportsMemory Protection UnitSecurity Attribution UnitM-Profile Vector Extension (MVE)Debug ScriptingExpressionsConstantsSystem VariablesPeripheral VariablesI/O PortsSerial PortsProgram Variables (Symbols)Fully Qualified SymbolsNon-Qualified SymbolsLiteral SymbolsUsing SymbolsLine NumbersBit AddressesType SpecificationsMemory Attribution SpecifiersOperatorsDifferences between µVision and CExpression ExamplesCode and Data Trace (Cortex-M)Trace FeaturesConfiguring TraceTracepoint ExpressionsTracepoint IntrinsicsTracepoint LimitationsTracepoint MarksTips and TricksReview Peripherals and CPU ConfigurationSimulate I/O PortsSimulate Interrupts and Clock InputsSimulate external I/O DevicesAssign Serial I/O to a PC COM PortCheck Illegal Memory AccessCommand Input from FilePreset I/O Ports or Memory ContentsWrite Debug Output to a FileKeyboard ShortcutsTPIU Initialization after RESET (Cortex-M)Prevent Opening FilesShow Japanese MessagesDebug CommandsDebug FunctionsSimulationFlash ProgrammingDialogsUtilitiesCommand LineExample ProgramsAppendixThe ASSIGN command allows using a PC COM Port as input for an UART in the µVision Simulator. If you enter the following commands, serial I/O is performed via the COM2 interface of your PC. The STIME variable allows to ignore the timing of the simulated serial interface.
ProductsDevelopment Tools | Hardware & Collateral | Downloads | Support | Contact |
Cookie Settings | Terms of Use | Privacy | Accessibility | Trademarks | Contact Us | Feedback Copyright © 2005-2019 Arm Limited (or its affiliates). All rights reserved. |
In this tutorial, we will learn to use I2C communication modules of TM4C123G microcontrollers. The TM4C123GH6PM microcontroller which is integrated on the Tiva Launchpad board has four I2C channels inside the chip such as 12C0, 12C1, 12C2, and I2C3. Firstly, We will use a bare-metal embedded approach to configure I2C modules using peripheral registers. Keil uvision IDE will be used to write program for I2C master and slave configuration.
I2C Communication Introduction
Keil Uvision Serialas
I2C is also known as an inter-integrated circuit or IIC or I square C. It is a synchronous half-duplex serial communication protocol. Furthermore, it is a multi-master bus protocol that requires only two wires to transfer data serially that are SCL and SDA.
- SDA ( Bidirectional data line)
- SCL ( Bidirectional clock line)
I2C Bus Connection
Each device connected with the I2C bus can be either in master mode or in slave mode. But only a master device can initiate the data transfer process. Usually, there are one master and one slave or multiple slave devices connects with the same I2C bus through pull-up resistors. Each salve address has a 7-bit unique address.
For example, if we configure the TM4C123G Tiva launchpad as a master device and we can connect multiple slave devices with the same bus.
For more information on I2C Communication, you can read this post:
TM4C123G I2C Communication Modules
As we mentioned earlier, TM4C123 microcontrollers have four I2C modules inside the chip. Moreover, each module can be configured either as a master, slave, or both master and slave at a time.
I2C Pins TM4C123 Tiva
This table shows the clock line and data line pins of each I2C module on TM4C123 pinout.
As you know that each GPIO pin of microcontroller has multiple functions or these pins are shared with different peripherals using multiplexing techniques. But each pin can be used for one peripheral or for one function at a given time. A peripheral select register is used to enable or disable the alternate function of every pin.
Keil Software Download
All these I2C modules supports four data transmission speeds.
- Standard (100 Kbps)
- Fast-mode (400 Kbps)
- Fast-mode plus (1 Mbps)
- High-speed mode (3.33 Mbps)
Steps configure TM4C123 I2C module as a Master
As we mentioned earlier, each I2C module can be configured either as a master or a slave. In this tutorial, we will see steps to configure the I2C3 module as a master. But you can follow the same steps to configure any I2C module in both master and slave configurations.
Enable Clock
- Enable clock to I2C3 module and GPIO pins which are used as SDA and SCL pins using RCGC12C3 and RCGCGPIO registers.
- Also, disable the ADC alternate functions of RD0 and RD1 pins using the GPIOAFSEL register and select the I2C3 alternate function using the GPIOPCTL register.
- Select Open drain operation for the I2CSDA pin that is the RD1 pin.
- Enable Master mode by setting appropriate bits of I2C3->MCR register.
Select Clock Speed
For example, we want to use speed of 100kbps. Select clock speed of 100kbps by using this formula:
(1 + TIME_PERIOD ) = SYS_CLK /(2*( SCL_LP + SCL_HP ) * I2C_CLK_Freq )
TIME_PERIOD = 16 ,000 ,000/(2(6+4) *100000) – 1 = 7
Load this time period value to I2C3->MTPR register.
Master Transmit Data
- Specify the slave address of the master and that the next operation is a Transmit by writing the
- I2CMSA register with a value of 0x0000.0076. This sets the slave address to 0x3B.
- Place data (byte) to be transmitted in the data register by writing the I2CMDR register with the
desired data. - Initiate a single byte transmit of the data from Master to Slave by writing the I2CMCS register with a value of 0x0000.0007 (STOP, START, RUN).
- Wait until the transmission completes by polling the I2CMCS register’s BUSBSY bit until it has been cleared.
- Check the ERROR bit in the I2CMCS register to confirm the transmit was acknowledged
You can follow the same steps to configure master to receive data from the slave.
TM4C123 I2C Code
In this code, we initialized the I2C3 module of TM4C123 microcontroller as a master. This example code can be used to transmit and receive multiple bytes. As you can see in this picture, RD0 and RD1 are data line and clock line pins of I2C3 module.
I2C Communication between Arduino and TM4C123 Launchpad
In order to test above code, we will peform I2C communication between Arduino and Tm4c123 Tiva launchpad. Arduino will be configured as a slave and TM4C123G microcontroller as a master. We will send an instruction from tiva launchpad to Arduino over I2C bus. The instruction will either turn on or turn off on board LED of Arduino board.
Make connection between Tiva C and Arduino according to this circuit diagram:
Upload this code to your Arduino Board. This Arduino code uses the I2C module of Arduino as a slave and the address assign to this slave device is 4. If a character received by this device is 0x00, it will turn on the onboard LED of Arduino and if a character received by this device is 0x01, it will turn off the onboard LED.
Pin A5 is clock, or SCL, pin) and pin 4 is a data, or SDA pin of Arduino Uno.
Upload this code to TM4C123G Tiva C Launchpad. This example code uses an onboard push button to transmit data to Arduino. If the push button is pressed, TM4C123 Tiva launchpad, transmit 0x00 and if not pressed, it transfers 0x01 via the I2C3 module.
Video Demo
Related Articles: