December 26, 2015

CC3200 Launchpad SimpleLink enabling UART

The below tutorial to enable and use UART is by using the CC3200 SDK library version 1.1.0 but it will be compatible with other versions as well.

First let me list the library header files that are required for this program.
Considering UART1
  1. rom_map.h
  2. hw_memmap.h
  3. prcm.h/prcm.c
  4. pin.h/pin.c
  5. uart.h/uart.c
  6. uart_hal.h/uart_hal.c

//Enable the UART peripheral clock
MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);

//Pin Configuration
// Configure PIN_01 (GPIO_10) for UART1_TX                   
MAP_PinTypeUART(PIN_01, PIN_MODE_7);
// Configure PIN_02 (GPIO_11) for UART1_RX
MAP_PinTypeUART(PIN_02, PIN_MODE_7);

//Set the UART1 Configurations (Clock, Baudrate, Data, Stop and Parity bits)
MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH), UART_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

Now, the UART1 is configured to work with GPIO pins 10 (TX) and 11 (RX) with baud rate as defined by the macro UART_BAUD_RATE and data length of 8 bits, 1 stop bit and no parity check. You can also choose different pin sets such as GPIO_16 as TX and GPIO_17 as RX or any other pin sets as defined in the technical reference manual.

Lets look at APIs to send and receive data. There are API defined to send and receive data both in non-blocking and blocking (polling) methods.

Blocking Codes - Waits for data reception or transmission completion by entering a conditional loop and blocking the cpu.

Non-Blocking Codes - Looks for data, data is retrieved if available or else, it continues executing the next instruction.

//Blocking codes

//Receive data
Data = UARTCharGet(UARTA1_BASE);

//Send data
UARTCharPut(UARTA1_BASE, Data);

//Non-Blocking codes

//Receive data
Data = UARTCharGetNonBlocking(UART1_BASE);

//Send data
UARTCharPutNonBlocking(UARTA1_BASE, Data);

Here, UART1_BASE is a macro defining the base memory location of UART1 as given in memory map in the Datasheet and is defined in hw_memmap.h. The variable 'Data' is the data received or sent. By using the UARTCharGet or UARTCharPut API inside a loop a string of data can be sent over serial port.

In the SDK, there are functions prefixed with 'MAP_' which are macros defined in rom_map.h which actually maps to the memory location of internal ROM where these APIs are pre-written as part of the servicepack. This reduces the size of binary file and serial flash utilization.

UART can also be used with interrupt enabled. For UART interrupt handling, visit CC3200 Launchpad - UART Interrupt handling.

Disclaimer:
The above article doesn't give you any guarantee and the sole purpose of this article is to share my learning in the way I understood. Any comments to refine this article are welcome with great pleasure. Please report any breaking link by commenting below.

No comments:

Post a Comment

Comment will be published after moderation only. Do not advertise here.

Receive all updates via Facebook. Just Click the Like Button Below

You can also receive Free Email Updates:

dgpride - Study Zone - Free Books - Tamil Lyrics

Copyright © 2008 -2012 dgpride. All rights reserved.

Subject/Topics

2 Marks (26) 8051 (1) AC Machines (7) Animations (1) Anna University Chennai (31) Arduino (4) ARM (3) Audio (1) Basic C Concepts (8) Basic Electronics (13) Basic principles (9) Book list (1) CAD (1) Chemical (2) Circuit theory (6) Civil (2) Cloud Computing (1) Communication (4) Competitive exams (2) Computer Architecture (4) Control system and components (9) CSE (40) Curriculum (4) DC Machines (9) Did you know (14) Digital (13) DLC (4) Documentation (1) DSP (1) EC 2201 (3) ECE (45) EDC (1) EEE (34) EIE (63) Electrical (35) Electronics (43) Electroplating (2) Emacs (1) Embedded basics (19) Embedded C Programming (19) Embedded Linux (5) Embedded System (22) Engineering basics (15) Environmental Science (1) Fibre Optics (1) Filters (2) FPGA (1) GATE (3) General (7) GNU (4) Handwritten (1) Hobbyist (15) How to (8) HTML (3) Humanities (2) IC Engines (7) ICE (5) Industrial Electronics (10) Industrial Instrumentatin (2) industrial process (2) Instrumentation (21) IoT (2) IT (2) Laboratory Manuals (17) LabVIEW (2) Lesson notes (2) LIC (2) Links (9) Linux (8) Magnetics (1) Management (1) Mechanical (5) Mechatronics (9) Microcontrollers (14) Microprocessors (9) Microsoft (1) Motivation (1) Must Know (11) Networks (1) NuttX (1) Objective type (1) Open Source (1) Opportunities (7) Oscillators (2) Part Time (1) Physics (1) Post Graduation (1) Power Electronics (12) Power Plant Engineering (2) Power Supplies (2) Previous GATE Papers (1) Process Control (2) Project (4) Protocol (1) R2008 (11) R2009 (1) R2013 (1) Recruitment (2) Research (2) Robotics (9) RTOS (3) Signal Processing (8) Signals and Systems (4) SMPS (1) Software tutorial (4) Stepper Motor (2) Syllabus (5) Texas Instruments (2) Thermodynamics (2) Training and Placement (6) Transducer Engineering (2) Transformer (2) Transmission (1) Tutorials (48) Two Marks (26) U-Boot (1) University Question Papers (16) Verilog (1) Video (4) Virtual Instrumentation (3) Visual Basic (21) VLSI (11) Web designing (4) Wi-Fi (3) Wireless (6)