Можете ли вы объяснить код сна / пробуждения процессора? - PullRequest
0 голосов
/ 06 августа 2020

Это код для моего wdt_handler.s

    .file   "_wdt_handler.c"
.text
    .balign 2
    .global WDT
    .section    __interrupt_vector_11,"ax",@progbits
    .word   WDT
    .text
    

    .extern redrawScreen
    .extern wdt_c_handler
WDT:
; start of function
; attributes: interrupt 
; framesize_regs:     24
; framesize_locals:   0
; framesize_outgoing: 0
; framesize:          24
; elim ap -> fp       26
; elim fp -> sp       0
; saved regs: R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15
    ; start of prologue
    PUSH    R15
    PUSH    R14
    PUSH    R13
    PUSH    R12
    PUSH    R11
    PUSH    R10
    PUSH    R9
    PUSH    R8
    PUSH    R7
    PUSH    R6
    PUSH    R5
    PUSH    R4
    ; end of prologue
    CALL    #wdt_c_handler
    ; start of epilogue
    POP R4
    POP R5
    POP R6
    POP R7
    POP R8
    POP R9
    POP R10
    POP R11
    POP R12
    POP R13
    POP R14
    POP R15
    cmp #0, &redrawScreen
    jz  ball_no_move
    and #0xffef, 0(r1)  ; clear CPU off in saved SR
ball_no_move:   
    RETI
    .size   WDT, .-WDT
    .local  count
    .comm   count,1,1
    .ident  "GCC: (GNU) 4.9.1 20140707 (prerelease (msp430-14r1-364)) (GNUPro 14r1) (Based on: GCC 4.8 GDB 7.7 Binutils 2.24 Newlib 2.1)"

Это код для моего основного. c

void main()
{
  P1DIR |= GREEN_LED; /**< Green led on when CPU on */
  P1OUT |= GREEN_LED;

  configureClocks();
  lcd_init();
  shapeInit();
  p2sw_init(15);
  buzzer_init();
  shapeInit();

  clearScreen(COLOR_WHITE);

  enableWDTInterrupts(); /**< enable periodic interrupt */
  or_sr(0x8);            /**< GIE (enable interrupts) */

  for (;;)
  {
    while (!redrawScreen)
    {                      /**< Pause CPU if screen doesn't need updating */
      P1OUT &= ~GREEN_LED; /**< Green led off witHo CPU */
      or_sr(0x10);         /**< CPU OFF */
    }
    P1OUT |= GREEN_LED; /**< Green led on when CPU on */
    redrawScreen = 0;
    drawString8x12(0, 70, "Welcome to Lab", COLOR_RED);
    drawString8x12(65, 75, "3", COLOR_RED);
    randomDraw(50, 20, COLOR_BLACK);
    drawRand(100, 150, COLOR_BLACK);
  }
}

void wdt_c_handler()
{
  u_int switches = p2sw_read();
  static short count = 0;
  P1OUT |= GREEN_LED; /**< Green LED on when cpu on */
  count++;
  if (count == 15)
  {
    stateAdvance_(); // assembly function not related to cpu
    count = 0;
  }
  P1OUT &= ~GREEN_LED; /**< Green LED off when cpu off */
}

Я понимаю, что в wdt_handler.s мы проводим сравнение для перерисовки экрана, если они оба равны нулю, то какая строка выполняется следующей? Что делает and #0xffef, 0(r1)?

Я изо всех сил пытаюсь понять, как процессор просыпается и спит, я знаю, что это очень расплывчато, но все помогает.

...