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 we need not explicitly program it.
Lets look at the source code.
Comments
Post a Comment