Port a 2 bit is 1 idling or 0 execute below commend

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: IAL SETTING ORG BSF MOVLW MOVWF MOVLW MOVWF MOVLW MOVWF BCF MOVLW MOVWF CLRF ;MAIN LOOP 0 STATUS,RP0 B'00000000' OPTIONR B'00001110' TRISA B'00000000' TRISB STATUS,RP0 1 PORTA PORTB ;Set TMR0 to timer ; Prescaler rate to 1:2 ;PORT A 0 bit is output ; 1-3 bit is input ;All of the PORT B is output ;PORT A 0 bit set to ‘1’ ; (supply power to 7-SEG) LOOP GOTO MOVF LOOP TMR0,W ;If PORT A 2 bit is ‘1’, idling, ; or ‘0’, execute below commend ;Obtain TMR0 value to Wreg ;Jump to SEGMENT_TABLE ;Transmit Wreg to PORTB GOTO SEGMENT_TABLE LOOP ANDLW 07H ADDWF PC RETLW B'00000110' RETLW RETLW RETLW RETLW RETLW RETLW RETLW ;Obtain 3 low bit of Wreg and save ;Add Wreg to PC(program counter) ;Exactly, jump to below as Wreg ; and excute. ;For example, Wreg is ‘2’, jump ; two line and execute next code. ;As a result, jump to one of below ; 8 code ;W dice ;0 1 ;1 2 ;2 3 ;3 4 ;4 5 ;5 6 ;6 your character1 ;7 your character2 ;Using 'RETLW' commend 8 times, ; this code save suitable value ; for display to Wreg, and return. ; previous position. END Table3. Code for Digital Dice (Incomplete) <Reference> [RETLW] Instruction Format: Operand: Operation: Description: Loads literal data into Wreg and returns. [label] RETLW k k: literal data (00∼256) k → Wreg, Stack → PC When returning from a subroutine, loads 8-bits literal data into the Wreg register, and move back to the calling program by loading the return address stored in Stack into PC register. Using MRPIC-IDE and ROM writer, compile the program code and write it to the PIC16F84. After putting the PIC16F84 chip into the breadboard providing the circuit for the digital dice, verify that it works as intended. If not, debugging should be followed. 6. Advanced Exercise Rewrite the main routine code in Exercise 1 (LED Control Program) using other instructions, and verify that it works as intended....
View Full Document

This note was uploaded on 11/21/2010 for the course MECHANICAL mae302 taught by Professor Jang during the Spring '10 term at Seoul National.

Ask a homework question - tutors are online