Skip to main content

Posts

Project 5 - LED Brightness using PWM (using libraries)

So far we have used and experimented on GPIO modules (in peripherals). Now in this tutorial/project we shall look into PWM module. From the datasheet of this micro-controller, this MCU has two PWM modules, namely PWM0 & PWM1. The on-board LED (R+B+G) is connected to PF1, PF2 and PF3 respectively. PF2 and PF3 module is connected to PWM1 module generator 3 and PF1 is connected to PWM1 module generator 2. This project will demonstrate the implementation of PWM1 gen3 to control the brightness of (G+B) LED. From this project onwards we will be using tivaware. Now lets see how to configure PWM module.  Steps to configure PWM module: Set PWM clock Enable PWM module Enable GPIO module (so that GPIO can be configured to PWM out) Set GPIO pins to PWM out Configure PWM pin modules Configure PWM generator (count up/count down/ count up-down) Set the PWM base frequency Set the PWM pulsewidth Enable output on PWM pins Enable PWM generator and set to run mode Progr...

Project 4 - LED Color change with buttons

With the concept of interfacing a push button form previous post , lets interface another push button which is connected to PF_0 as SW2. But PF_0 has an alternative function which is MISO of spi-1. So because of this we need to follow the below mentioed procedure to read data from PF_0 pin. Before we learn how to read data from PF_0, let look into GPIO_LOCK and GPIO_CR registers. GPIO_LOCK: This register controls the write access to GPIO_CR . Writing 0x4C4F434B to this register unlocks GPIO_CR , writing any other value enables the lock on GPIO_CR . After the GPIO_CR is updated or written with new values, it reapplies the lock. This process needs to be repeated every time GPIO_CR register needs to be written. GPIO_CR: This is a commit register. The value of this register determines which bits of GPIO_AFSEL, GPIO_PUR, GPIO_PDR, GPIO_DEN are committed when write to these registers is performed. If the bit in the GPIO_CR   is cleared, the corresponding ...

Project 3 - Onboard push button

After learning how to interface LED and flash it in various patterns, now we shall step over to interface onboard push button (SW1/PUSH1) and turn LED on and off based on the push of SW1. Now, before we look into the code, we need to know why it is best to have push button or in the matter of fact any interrupt as active low... Firstly it reduces the hardware requirement and in terms of electrical signal, the microcontroller can register when the button is pushed or pressed. If it is active high, then any signal with amplitude (50-75% of VDD) will be registered as button is pushed even if it is not. Hence it is recommended to use active low. So to make the MCU register the push, we need to have the pull up on the input pin. Therefore lets introduce new register "GPIOPUR" - GPIO pull up register. This register is also associated with the current driver register "GPIODR2R" - GPIO - 2mA drive select register. This register is set by default for all pins, so w...

Project 2 - Flashing all onboard-LED colour combinations

From the previous project we have seen how to blink LED (white colour). This project post will demonstrate how to flash the on board LED colour combinations without much math. So the LED is connected as follows. RED → PF1 BLUE → PF2 GREEN → PF3 Therefore to display red we need to output 0x02, here '2' because PF0 is not being used. Similarly to display purple/violet → 0x06, blue → 0x04, aqua blue/ greenish blue → 0x0c, green → 0x08, yellow  → 0x09, white  → 0x0e and none  → 0. Now lets focus on the sequence: 0, R, RG, G, GB, B, RB, RGB. For the above mentioned sequence the system states are as follows: Here the states are addressed as D2D1D0 and the next state as O2O1O0 Present State     Next State     Output       000                  001              000       001            ...

Project 1 - LED Blink (without libraries)

So lets get started with the first basic project with TM4C123GXL eval board. Objective of this project is to blink on board LED (R+G+B) without libraries or tivaware. *Port F2 is connected to blue and F3 to green Launch Code composer studio or other relevant IDE. In CCS, open a new CCS project. Select "Tiva C series" and "Tiva TM4C123GH6PM" as target and "Stellaris In-Circuit Debug Interface" as connection. Assign a Project Name and click on "Finish". According to objective, tivaware or libraries are not used in this project else we need to include the tivaware location as mention in the link provided in the project home page of this project series, in the include option in the "properties/build/include options". Double click on main file and start programming. Program:  Click here to view the file Back to Project Home Page .

Getting started with TM4C123GXL

The Tiva™ C Series TM4C123G LaunchPad Evaluation kit package includes LaunchPad Board USB cable ReadMe pamphlet On the first power up of the board, a demo program executes. Reset button resets the mcu and the LED glow pattern restarts. User buttons Sw1 and Sw2 are used to move LED glow pattern back and forth. If both the user buttons are pressed at once for 3 secs, the mcu goes into hibernate mode and can be resumed by pressing Sw2. On connecting the board via TTY terminal, it provides a prompt '>'. Type "help" for information. Try experimenting with the other commands. To connect the board via serial port plugin the usb cable into debug port and let the switch be in debug position. This switch routes power from debug usb port or device/otg usb port. For information on ports provided by this board, refer the ReadMe pamphlet. Back to Project Home Page .

TM4C123GH6PMI Specifications

Specifications: CPU: 32-bit ARM® Cortex™-M4F clocked at 80 MHz FPU: IEEE754 - compliant single-precision FPU Performance: 100DMIPS SRAM: 32KB single-cycle ROM: 256KB Flash EEPROM: 2KB Peripherals GPIO: 6 blocks UART: 8 SSI: 4 I2C: 4 CAN: 2 USB: OTG/Device DMA: 32-channel configurable μDMA Controller Timer: 6 -16/32-bit GPTM blocks 6 - 32/64-bit Wide GPTM blocks WDT: 2 Hibernation Module: 2 PWM: 2, each with 4 PWM generator blocks and a control block, for a total of 16 PWM outputs QEI: 2 ADC: 2, 12 bit modules with max sampling rate of 1MSPS ACC: 2 JTAG: 1 Refer Datasheet for more details. Back to Project Home Page .