Skip to main content

Posts

Showing posts from January, 2018

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 bit in ab

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