hp 20b rpn calculator
play

HP 20b RPN Calculator By Jayne (Jay) Shim & SonYon (Sonny) - PowerPoint PPT Presentation

HP 20b RPN Calculator By Jayne (Jay) Shim & SonYon (Sonny) Song ? THE PROCESSOR CAPP1 TDI CAPM1 TDO Charge ICE ARM7TDMI CAPP2 JTAG TMS Pump CAPM2 SCAN Processor TCK VDDINLCD JTAGSEL VDD3V6 LCD VDDLCD System


  1. HP 20b  RPN Calculator By Jayne (Jay) Shim & SonYon (Sonny) Song

  2.  ?

  3. THE PROCESSOR CAPP1 TDI CAPM1 TDO Charge ICE ARM7TDMI CAPP2 JTAG TMS Pump CAPM2 SCAN Processor TCK VDDINLCD JTAGSEL VDD3V6 LCD VDDLCD System Controller Voltage Regulator VDDIO2 TST 2 MHz RCOSC FIQ 1.8 V VDDIO1 AIC Voltage IRQ0-IRQ1 PIO GND Regulator VDDOUT PCK0-PCK2 VDDCORE CLKIN VDDIO2 Memory Controller SRAM PLLRC PLL PMC Embedded Address 2 Kbytes( Back-up) Flash XIN Decoder 4 Kbytes (Core) OSC Controller XOUT Abort Misalignment 32k RCOSC Status Detection VDDCORE Flash VDDIO1 BOD ERASE 64/128 Kbytes Supply VDDIO1 POR Controller Peripheral Bridge NRST ROM (12 Kbytes) Peripheral Data NRSTB PGMRDY Controller PGMNVALID Fast Flash 11 Channels PGMNOE Programming PGMCK FWUP Interface PGMM0-PGMM3 VDDIO1 PGMD0-PGMD15 PGMNCMD PGMEN0-PGMEN2 APB SAM-BA RTC PIT WDT PWM0 PWM1 PWMC PDC DRXD PWM2 PIO DBGU PWM3 DTXD PDC TCLK0 Timer Counter TCLK1 TCLK2 PIOA (26 IOs) TIOA0 TC0 TIOB0 TIOA1 PIOB (24 IOs) TC1 TIOB1 TIOA2 TC2 TIOB2 PIOC (30 IOs) PIO PDC TWI TWD TWCK SEG00-SEG39 PDC COM0-COM9 NPCS0 PDC LCD Controller NPCS1 NPCS2 NPCS3 SPI MISO RXD0 PDC MOSI TXD0 PDC SPCK SCK0 USART0 PDC ADTRG RTS0 PDC AD0 CTS0 PIO AD1 RXD1 PDC AD2 TXD1 ADC AD3 SCK1 RTS1 USART1 ADVREF CTS1 DCD1 DSR1 DTR1 PDC RI1

  4. Liquid Crystal Display (LCD)

  5. The Keyboard  Keyboard Matrix Keyboard connected to processor 

  6. 12 x 3 = 36 12 ÷ 3 = 4 ERROR

  7. 12 x 3 = 36 1. ENTER “1” 2. ENTER “2” 12 3. INPUT  12 

  8. 12 x 3 = 36 4. Enter “3” 3 12 3 

  9. 12 x 3 = 36 5. MULT “ × ” 36 36 

  10. What about... a complex complex expression? expression?!

  11. ((2 + 3) × 5) × 6 1. Enter “2” 2 2. INPUT  2 

  12. ((2 + 3) × 5) × 6 3. Enter “3” 3 2 3 

  13. ((2 + 3) × 5) × 6 4. ADD “+” 5 5 

  14. ((2 + 3) × 5) × 6 5. Enter “5” 5 5 5 

  15. ((2 + 3) × 5) × 6 6. MULT “ × ” 25 25 

  16. ((2 + 3) × 5) × 6 7. Enter “6” 6 25 6 

  17. ((2 + 3) × 5) × 6 8. MULT “ × ” 150 150 

  18. ERROR: ERROR: EMPTY EMPTY STACK STACK 1. MULT “ × ” Empty Stack 

  19. OTHER USEFUL KEYS

  20. Backspace (  ) 7 Press Backspace “  ” 0

  21. Sign ( +⁄− ) 7 Press Sign “ +⁄− ” -7

  22. Getting Started: Hello World #include "AT91SAM7L128.h“ #include "lcd.h" int main() { int number = 999 ; int digit; int lcdIndex = 11; / lcd_init(); if (number > 999999999 || number < -999999999) { lcd_put_char7('O', 0); lcd_put_char7('V', 1); lcd_put_char7('E', 2); lcd_put_char7('R', 3); lcd_put_char7('F', 4); lcd_put_char7('L', 5); lcd_put_char7('O', 6); lcd_put_char7('W', 7); }

  23. Getting Started: Hello World else { if (number > 0) { while (number > 0) { digit = number % 10; number = number / 10; lcd_put_char7(digit+48, lcdIndex); lcdIndex--; } } else if (number == 0) { lcd_put_char7(48, lcdIndex); } else if (number <0) { while (number < 0) { digit = number % 10; digit = digit*-1; number = number / 10; lcd_put_char7(digit+48, lcdIndex); lcdIndex--; } if (number == 0) { lcd_put_char7(45, 0); } } } return 0; }

  24. Listening to the Keyboard const char keyboard_layout [7][6] = {{'N', 'I', 'P', 'M', 'F', 'A'}, {'C', 'R', 'N', 'B', '%', 'L'}, {'T', '(', ')', 'G', '<', '_'}, {'U', '7', '8', '9', '/', '_'}, {'D', '4', '5', '6', '*', '_'}, {'S', '1', '2', '3', '-', '_'}, {'O', '0', '.', '=', '+', '_'}};

  25. Listening to the Keyboard char keyboard_key() { int column; int row; char button; for (column = 0; column <= COLUMN; column++) { keyboard_column_low(column); for (row = 0; row <= ROW; row++) { if(!keyboard_row_read(row)) { keyboard_column_high(column); button = keyboard_layout[column][row]; return button; } } keyboard_column_high(column); } return 0; }

  26. Listening to the Keyboard int main() { for (;;) { char key = keyboard_key(); if (key != 0) { for(j = 0; j < 14; j++) { lcd_put_char7(' ',j); } lcd_put_char7(key,11); } else { lcd_print7("no key pressed"); } } return 0; }

  27. Entering and Displaying Numbers void keyboard_get_entry(struct entry *result) { int input = 0; int counter = 0; int sign = 1; for (;;) { int c = keyboard_key(); if (c <= '9' && c >= '0') { input = input * 10 + (c - '0'); counter++; } else if (c == '~') { sign *= -1; } else if (c == '\b') { input /= 10; if(input == 0) lcd_put_char7(' ', 11); } else if (c != -1){ result->operation = c; break; }

  28. Entering and Displaying Numbers while (c != -1) { c = keyboard_key(); } if (input != 0) lcd_print_int_neg(sign == -1, input); } if (counter == 0) { result->number = INT_MAX; } else { result->number = sign*input; } }

  29. Entering and Displaying Numbers int main() { struct entry entry; *AT91C_WDTC_WDMR = AT91C_WDTC_WDDIS; lcd_init(); keyboard_init(); lcd_print7("PRESS"); while (1) { keyboard_get_entry(&entry); if (entry.operation != 0 && entry.number! =INT_MAX) { lcd_print_int(entry.number); lcd_put_char7(entry.operation, 0); entry.operation = 0; } } return 0; }

  30. An RPN Calculator void calculate(char operation, int index, int *stack) { if (index < 0) { lcd_print7("ERROR"); } else { int n1 = stack[index]; int n2 = stack[index+1]; switch (operation) { case '+': stack[index] = n1 + n2; break; case '-': stack[index] = n1 - n2; break; case '*': stack[index] = n1 * n2; break; case '/': stack[index] = n1 / n2; break; } stack[index+1] = 0; lcd_print_int (stack[index]); } }

  31. An RPN Calculator int main(){ int stack [50]; int index = 0; while (1) { keyboard_get_entry(&entry); if (entry.operation != 0 && entry.number!=INT_MAX) { stack[index] = entry.number; lcd_print_int(entry.number); if (entry.operation == '\r') { index++; } else if (entry.operation == '+' || entry.operation == '-' || entry.operation == '*' || entry.operation == '/') { index--; calculate(entry.operation, index, stack); index++; } } else if (entry.operation == '+' || entry.operation == '-' || entry.operation == '*' || entry.operation == '/') { if (index >= 2) { index = index - 2; calculate(entry.operation, index, stack); index++; } else { lcd_print7("ERROR"); } } } }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend