An Old Timer
This is a self contained project that demonstrates how to use the Timer component to measure the duration of a button push.
It is one of my tests of the Timer (2.5) component.
This picture may look simple but there's a bit going on here:
The Timer (2.5) component is configured as a resettable One Shot Timer with trigger and capture
The Timer is triggered upon the depression of the push button
The capture is performed upon the release of the push button
The timer is rearmed on demand
I'm using a 4x16 LCD Character Display.
The Character LCD Component is used but according to its datasheet it is only designed to operate with a 16 x 2 line LCD display.
To make it work with the particular 16 x 4 display some adjustments are required:
- 5x7 font.
- 4 lines
My adjustments have been engineered not to require any changes to the component's source code. They are;
1. Font selection - The appropriate configuration bit requires adjustment.
The initialisation requires the following to be added immediately after the LCD_Char_Start() API.
LCD_Char_WriteControl(LCD_Char_DISPLAY_2_LINES_5x10 & ~(0x04));
(Note: Ideally, the 0x04 numeric constant should be replaced with a suitable symbolic constant).
2. Cursor positioning - The additional two lines reside in the memory space of the first two lines.
This is a rather simple adjustment using a wrapper function.
void MC_LCD_Char_Position(uint8 x, uint8 y) {
if ((x >= 2) && (x <=3)) {
LCD_Char_Position(x - 2, y + 16);
} else {
LCD_Char_Position(x, y);
}
}
There is a limitation to the use of the Character LCD component. All of the interface pins must reside on consecutive pins on the same port.
If you look at the photo above you will notice that I have connect the LCD component to Port 2[6:0]. Pin 2.6 is on the far side of the PCB relative to its sibling pins so it is connected with an extension lead.
During my research I spotted an error in the component datasheet so I hope someone from Cypress will revise it with the correction.
That is the description of Constant LCD_Char_DISPLAY_2_LINES_5x10 in the table.
What reads as;
"Set display to be 2 lines 10 characters"
should read as;
“Set display to be 4-bit interface, 2 lines of 5x10 pixel characters.”
Enjoy the short video!


Top Comments