MCU key reading subroutine, MCU calling subroutine

Updated on technology 2024-02-08
8 answers
  1. Anonymous users2024-02-05

    void key0()

    if(p1_0!=1) *If the key 0 is pressed.

    delay10ms();*Delay 10 ms This segment is the stabilization, if(p1 0!).=1) *If you still press it.

    while(!p1_0)

    if(p1 0) if picked up.

    break;

    fige=1 indicates that the key has been pressed and lifted, and it is ready to be handled.

    Program description: The port is connected to the button, and the low level is pressed.

    The function of this part of the program: to detect whether the key is pressed, to stabilize the shake. Also make sure to confirm that the button was pressed only once.

    When you press it and don't let go, don't do the key. Only after the following process: press, let go. button to process.

  2. Anonymous users2024-02-04

    ea=1, which is equivalent to enable all interrupt. Indicates that interrupts are allowed, and instead of calling timer0, timer0 is allowed to generate interrupts and execute the contents of the timer0 interrupt function.

  3. Anonymous users2024-02-03

    ea=1 should be the total disconnect.

    void time0() interrupt 1 is the timer interrupt time to enter this function.

  4. Anonymous users2024-02-02

    The total interrupt of the EA is re-allowed, and only when EA=1, the CPU will interrupt the system accordingly. void time0() interrupt 1 is a timer 0 interrupt subroutine. When the time is up, apply to the CPU for interrupt, at this time, if DAO is EA=1, it responds to the interrupt and enters the interrupt subroutine; If ea=0, the interrupt does not respond and does not enter the subroutine.

    If the software does not change the initial value of the timer, it applies to the CPU for an interrupt until EA=1 and responds to an interrupt.

    That's probably what it means

  5. Anonymous users2024-02-01

    Architecture:

    Main function Call subfunction 1 Exit subfunction 1, return main function Call subfunction 2 Exit subfunction 2, return main function.

    Do you understand, the program can't be stuck in the subfunctions, it must execute each subfunction in a loop.

    As a subfunction, you can not act, but you can't occupy the pit without!

  6. Anonymous users2024-01-31

    Check the hardware first, short-circuit a button, and see how much is returned.

  7. Anonymous users2024-01-30

    sysem_initial();Initialize the program.

    and the following, the difference is one "void".

    void sysem_initial()

    In addition, there are a lot of logical errors.

    The problem is C: Error C129: Missing';' before 'key_scan'》

    Hehe, this error, the most critical place is:

    #include

    define uint unsigned int program, this line is missing.

    define uchar unsigned char In general, this line should also be added.

  8. Anonymous users2024-01-29

    #include

    uchar key_scan();Key scanning subroutines.

    void delay10ms();Delay program.

    uchar key_free();Wait for the key to release the program.

    void key_deal();

    sysem_initial();Initialize the program.

    void main()

    void sysem_initial()

    uchar key_scan()

    else if(p1&0x03==0x02) if the second row has a bond closed.

    key=j*8+i;

    if(j==0||j==1) Scan the key.

    break;Quit.

    rankcode=(rankcode<<1)|0x01;Otherwise, start scanning the next column}}

    return(key);Returns a key-value.

    uchar key_free()

    void delay10ms()

    between needs; , you can not add it directly;

    And all the while() you are waiting for above are required later; This is an empty wait, otherwise it is executed with the following statement instructions.

Related questions
6 answers2024-02-08

Crash, it may be that the on-site interference is too severe. Anyway, even have abandoned chips that don't have internal program memory and EEPROM. The reason is that it is often not a program problem, but a board and PCB design problem. >>>More