Advertisement
prison_lox

Lab 2 - Task 2.4 + 7 Segment

Oct 1st, 2023 (edited)
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.07 KB | None | 0 0
  1. #include<p18F4550.inc>
  2.  
  3. CONFIG FOSC = HS ; H oscillator, HS used by USB
  4. CONFIG WDT = OFF ; HW disabled - SW Controlled ( deactivation des watchdog timer)
  5. CONFIG DEBUG = OFF
  6. CONFIG MCLRE = OFF ;
  7. CONFIG CPUDIV = OSC1_PLL2
  8. CONFIG PBADEN = OFF
  9.    
  10. counter_value equ H'04'
  11.  
  12.    
  13. RES_VECTOR CODE 0x0000;
  14. goto init
  15.  
  16. org 0x0008 ; interrupt vector at PM address 0x0008
  17. goto irq_handle ; go to the function for the   
  18.  
  19.  INT0_interrupt
  20.     bcf INTCON , INT0IF ; clear the flag
  21.  
  22.     bsf PORTC, RC0
  23.     retfie
  24.  
  25. irq_handle ; --- interrupt routine
  26.     btfsc INTCON , INT0IF
  27.     goto INT0_interrupt ; yes , it is TMR0
  28.     retfie ; --- no , return from interrupt
  29.  
  30. MAIN_PROG CODE
  31.  
  32. init
  33.     clrf TRISC ; set PORTC as output
  34.     clrf PORTC ; clear PORTC
  35.    
  36.     setf TRISB ;
  37.     clrf PORTB ; clear PORTB
  38.    
  39.     bsf INTCON , GIE ; activate interrupts
  40.     bsf INTCON , INT0IE ; activate external interrupt
  41.     bsf INTCON, INTEDG0 ; interrupt on rising edge
  42.     goto main_loop
  43.  
  44.    
  45. main_loop
  46.     bcf PORTC, RC0;
  47.     goto main_loop ; push skipped
  48.    
  49. END  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement