02 Unit 8 Assignment

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Jeff Brown Microprocessing Mr.

Hamza 08-01-13
Chapter 11: Problems 1, 2, 4, 17, 18, 21, 22, 29, 30, 33-38, 45, 46, 49, 50, 57, 60, 66, 67, 32, 47, 62

1. interrupt 2. Timer, hardware, serial 4. True 17. 16 bytes (8 words) 18. False 21. False 22. 8 bytes (4 words) 29. When TMR1H:TMR1L rolls from FFFFH to 0000H then Timer1 flag is raised and it is directed to low or high priority vector location to execute the ISR. 30. When TMR1H rolls over from FF to 00 33. False 34. 0x0008 if high priority and 0x0018 if low priority, Pins 33, 34, and 35 35. INTCON, BSF INTCON, INT0IE 36. INTCON3 BSF INTCON3,INT1IE 37. BSF INTCON, INT0IE BSF INTCON3,INT1IE BSF INTCON3,INT2IE 38. When the input signal goes from high to low the processor finishes executing the current instruction and jumps to ROM location 0x008 to execute the ISR. 45. In order to allow the interrupt to come in, INT1IE must be set to high. It is only after INT1IE = 1, that INT1IF being high will cause the CPU to jump to a vector location. INT1IF can become high by external pulse or by an instruction. In some applications to simulate interrupts we can use an instruction to set INT1IF to cause an interrupt. 46. When the input signal goes from high to low the processor finishes executing the current instruction and jumps to ROM location 0x008 to execute the ISR. The CPU makes GIE = 0, blocking another interrupt from the same source or any other source. At the end of the ISR the RETFIE instruction will make GIE = 1, allowing another interrupt to come from the same source. 49. Falling is the transition from high to low, Rising is the transition from low to high 50. Clear the appropriate bit in INTCON2 register 57. True 60. The code executing is interrupted and the CPU jumps to the ISR to write another byte to TXREG. 66. INT0 is always high priority. This is the only interrupt that does not have the option of changing the priority. 67. IPR1, BCF IPR1, TMR1IP 32. ORG 0000H GOTO MAIN ;bypass interrupt vector table ;-on default all interrupts land at address 00008 ORG 0008H ;interrupt vector table

BTFSS PIR1,TMR1IF ;Timer1 interrupt? RETFIE ;No. Then return to main GOTO T1_ISR ;Yes. Then go Timer1 ISR ;-main program for initialization and keeping CPU busy ORG 00100H ;after vector table space MAIN BCF TRISB,7 ;RB7 as an output CLRF TRISD ;make PORTD output SETF TRISC ;make PORTC input CLRF T1CON ;Timer1,16-bit, ;no prescale,internal clk MOVLW 0xFE ;TMR1H = FEH, the high byte MOVWF TMR1H ;load Timer0 high byte MOVLW 0x5F ;TMR1L = 5FH, the low byte MOVWF TMR1L ;load Timer1 low byte BSF PIE1,TMR1IE ;enable Timer1 interrupt BCF PIR1,TMR1IF ;clear timer interruupt flag bit BSF T1CON,TMR1ON ;start Timer1 BSF INTCON,PEIE ;enable peripheral interrupts BSF INTCON,GIE ;enable interrupts globally ;--keeping CPU busy waiting for interrupt OVER MOVFF PORTC,PORTD ;send data from PORTC to PORTD BRA OVER ;stay in this loop forever ;--------------------------ISR for Timer 0 T1_ISR ORG 200H MOVLW 0xFE ;TMR1H = FEH, the high byte MOVWF TMR1H ;load Timer1 high byte MOVLW 0x5F ;TMR1L = 5FH, the low byte MOVWF TMR1L ;load Timer1 low byte BTG PORTB,7 ;toggle RB7 BCF PIR1,TMR1IF ;clear timer interrupt flag bit EXIT RETFIE END 47. ORG 0000H GOTO MAIN ;bypass interrupt vector table ;-on default all interrupts go to to address 00008 ORG 0008H ;interrupt vector table BTFSC PIR1,RCIF ;Is interrupt due to transmit? BRA RC_ISR ;Yes. Then go to ISR RETFIE ;No. Then return ORG 0040H RC_ISR ;service routine for RCIF MOVFF RCREG,PORTD ;get new value, clear RCIF RETFIE ;then return to main ;-the main program for initialization ORG 00100H MAIN

CLRF TRISD ;make PORTD output BSF TRISB,4 ;make RB4 an input BCF TRISC,7 ;make RC7 an output MOVLW 0x90 ;enable receive and choose ;low baud MOVWF RCSTA ;write to reg MOVLW D'15' ;9600 bps ;(Fosc / (64 * Speed) - 1) MOVWF SPBRG ;write to reg BSF TRISC, RX ;make RX pin of PORTC an ;input pin BSF RCSTA, SPEN ;enable the serial port BSF PIE1,RCIE ;enable TX interrupt BSF INTCON,PEIE ;enable peripheral interrupts BSF INTCON,GIE ;enable interrupts globally AGAIN BTFSS PORTB,4 ;bit test RB4 GOTO OVER BSF PORTC, 7 ;set RC7 GOTO AGAIN OVER BCF PORTC, 7 ;clear RC7 GOTO AGAIN ;stay in this loop forever END 62. ORG 0000H GOTO MAIN ;bypass interrupt vector table ;-on default all interrupts go to to address 00008 ORG 0008H ;interrupt vector table BTFSC PIR1,RCIF ;Is interrupt due to transmit? BRA RC_ISR ;Yes. Then go to ISR RETFIE ;No. Then return ORG 0040H RC_ISR ;service routine for RCIF MOVFF RCREG,PORTD ;get new value, clear RCIF RETFIE ;then return to main ;-the main program for initialization ORG 00100H MAIN CLRF TRISD ;make PORTD output BSF TRISB,4 ;make RB4 an input BCF TRISC,7 ;make RC7 an output MOVLW 0x90 ;enable receive and choose ;low baud MOVWF RCSTA ;write to reg MOVLW D'15' ;9600 bps ;(Fosc / (64 * Speed) - 1) MOVWF SPBRG ;write to reg

BSF TRISC, RX ;make RX pin of PORTC an ;input pin BSF RCSTA, SPEN ;enable the serial port BSF PIE1,RCIE ;enable TX interrupt BSF INTCON,PEIE ;enable peripheral interrupts BSF INTCON,GIE ;enable interrupts globally AGAIN BTFSS PORTB,4 ;bit test RB4 GOTO OVER BSF PORTC, 7 ;set RC7 GOTO AGAIN OVER BCF PORTC, 7 ;clear RC7 GOTO AGAIN ;stay in this loop forever END

You might also like