Study Notes
for
redesigned
2012-09-06
versions : 12_09_01
All
Here I mainly record my method of using matrix keyboard to input data. In system design, data input is often encountered, and matrix keyboard is the most commonly used input device. If there is no problem with the scanning of matrix keyboard, how to use matrix keyboard to input data, for example, I want to input the number 253.45, how to achieve it.
Here are the two implementations I used:
First, it borrows a strange value, that is, a value that cannot be scanned when the keyboard is scanned. This number has nothing to do with the keyboard. It is mainly used to mark that a new key has been pressed. I use the interrupt detection key of msp430g2553. The principle is that when any key is pressed, it will enter the interrupt function, and then judge which key is pressed in the interrupt. The basis for realizing this method is that the 8 IO ports of an IO port group of msp430g2553 (such as P1, P2) share an interrupt vector. In a group, no matter which IO port triggers the interrupt, it will enter the same interrupt. So in this way, you can use the interrupt to determine whether a key has been pressed, and then further judge which key is pressed in the interrupt. This saves a lot of microcontroller resources compared to the method of using loop scanning. When the key is not pressed, there is no need to keep scanning the key in a loop. The program of the keyboard interrupt part is as follows:
//
#pragma
__interrupt
{
uchar
_DINT();
P1DIR
delay_ms(5);
temp
key=99;
// Mainly used to mark that a new key has been pressed
if(temp==0x01)
{
key=1;
}
else
{
key=2;
}
else
{
key=3;
}
else
{
key=4;
}
else
{
key=5;
}
else
{
key=6;
}
else
{
key=7;
}
else
{
key=8;
}
else
{
key=9;
}
else
{
key=0;
}
else
{
key=11;
t_flag=3;
key_flag
key_count=0;
set_t=0.0;
}
else
{
key=12;
t_flag=4;
key_flag
key_count=0;
set_time=0;
}
else
{
key=13;
t_flag=1;
}
else
{
key=14;
t_flag=2;
}
else
{
key=15;
t_flag=0;
}
if(key_flag==1)
{
if(key!=99)
{
set_t=set_t*10+key;
// wr_int(4,1,set_t);
key=99;
key_count++;
// wr_int(3,3,key_count);
if(key_count==4)
{
set_t=(float)set_t/10;
wr_float_3(4,1,set_t);
key_flag=0;
key_count=0;
}
}
}
if(key_flag==2)
{
if(key!=99)
{
set_time=set_time*10+key;
wr_int(4,2,set_time);
key=99;
key_count++;
// wr_int(3,2,key_count);
if(key_count==4)
{
set_time_1=set_time;
// wr_int(3,2,set_time);
int_flag=1;
key_flag=0;
key_count=0;
}
}
}
//
_EINT();
}
The second method is to use an array to temporarily store the pressed values, and then combine them to form the desired values. The number of elements in the array is the total number of digits of the data you want to enter. The procedure is as follows:
//
#pragma
__interrupt
{
uchar
uchar
//
}
//Corresponding button functions: *: Set temperature button
Previous article:Temperature control program part report - based on msp430g2553
Next article:My TLC2543 study notes - based on the msp430g2553 microcontroller
Recommended ReadingLatest update time:2024-11-15 07:43
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- [National Technology N32G457 Review] OLED screen display driver and RTC electronic clock
- Things to note when writing programs based on TMS320 series DSP using C/C++
- "STM32 Library Development Practical Guide", a must-have for STM32 development!
- C language version of the time library function file or timestamp conversion algorithm
- To ensure the stability of electronic equipment, what tests need to be done on the hardware?
- Evaluation Weekly Report 20220801: Canaan K510 AI Development Kit is launched, and a domestic FPGA is expected to be launched this week~
- Why is the safety spacing of the board edge set in Altium Designer 18 invalid?
- Series and parallel circuits of common resistors
- Will the tuition be higher if I pursue graduate studies after I start working?
- Add C66x CSL library and header files to the project in CCS