Hi, All.
Could you please help me connecting properly a Keypad (or Keyboard, if possible) and a LCD (or Monitor, if possible) to DEMO9S12XEP100?
Thanks in advance!
PC
Hi Pablo,
About keypad)
Keypad is typically just matrix of switches. So, you have rows and columns signals (typically 3x4 or 4x4) and switches between these lines. So, typically we just add pull-ups at either row or column signals. All signals (7/8 wires) will be connect to MCU. We could use pin interrupt for detection of keypad action. Since only one interrupt is generated for any pin event on port, it has sense to connect all lines to one port or at least all row/column signals keep on one port with interrupt capability.
Pin interrupt capability on S12XEP100 is available at ports P, H and J.
So, for example:
#pragma CODE_SEG NON_BANKED
interrupt 56 void PORTP_ISR(void)
{
//there's only one interrupt vector for whole port P
if(PIFP_PIFP0 == 1)
{
PORTA_PA0 = ~PORTA_PA0; //any action, for example toggle LED on PA0
PIFP_PIFP0 = 1; //clear interrupt flag
}
//check all other flags if more interrupts have been enabled
}
#pragma CODE_SEG DEFAULT
void PortP_Init(void)
{
DDRP = 0x00; //Port P as input
PPSP = 0x00; //falling edge, pull up resistor
PERP = 0xFF; //internal pull up resistor enabled
PIEP = 0xFF; //interrupt enable for all port P pins
}
So, combination of two low values will tell you which of buttons was pressed.
About LCD)
Some of S12(X) MCUs has already LCD driver (like S12HY, S12XHY, S12ZVH,..), unfortunately S12XEP100 don’t have such module. We could simulate it by software.
There is AN3219 XGATE Library TN STN LCD Driver:
http://www.freescale.com/files/microcontrollers/doc/app_note/AN3219.pdf
http://www.freescale.com/webapp/sps/download/license.jsp?colCode=AN3219SW
Another option (simpler) is using LCD with build in driver.
Old students learning project board PBMCUSLK was assembled by 8x2 display where four wire communication was established trough SPI and parallel-out shift register 74HC595.
http://www.freescale.com/products/archived/mcu-project-board:PBMCUSLK
HCS12 SLK Demonstration CodeWarrior Project contains code for sending data to this display.
http://www.freescale.com/products/archived/16-bit-microcontroller-student-learning-kit:HCS12CSLK
In case of LCD display drivers, the Hitachi HD44780 LCD controller control interface and protocol is a de-facto standard for this type of display.
In attachment you can find draft of HD44780 driver for S12XDP512 from my colleague. You can use it as inspiration for your own solution.
Another option is using eGUI software:
or any commercial solution…
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Excellent answer!!
Thanks to you, very much!!
Pablo.