Summary of MSP430 microcontroller programming ideas (2)

9. The CPU "no omission" inquires about the occurrence of events, which is an important reason for generating blocking codes; as long as the WDT interrupt time is shorter than the duration of a keystroke, the keystroke will not be missed. As long as it is longer than the glitch duration, no more events will be detected.
10. The criterion for button press is front high and then low, and the criterion for button release is front low and then high.
void P1_IODect()
{
 static unsigned char KEY_Now=0; //Unsigned char should be reserved when the variable value is out of the function
 KEY_Past=0;
 KEY_Past=KEY_Now;
 //-----Query the input register of IO-----
 if( P1IN&BIT3) KEY_Now=1;
 else KEY_Now=0;
 //-----The previous high level, the next low level, indicating that the key is pressed-----
 if((KEY_Past==1)&&(KEY_Now ==0))
  P13_Onclick();
}
11. For display applications, memory isolation is also a common programming idea. Create a video memory array in RAM, and call the function to rewrite the video memory array if the CPU wants to display what content

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325292686&siteId=291194637