130 likes | 379 Views
16F84A Interrupt. 4 interrupt sources: External Rb0 interrupt pin. Portb<7:4> interrupt on change TMR0 Timer overflow Data EEPROM write complete. Timer Interrupt. void interrupt( void ) // interrupt service routine // call 15 times every second {
E N D
16F84A Interrupt • 4 interrupt sources: • External Rb0 interrupt pin. • Portb<7:4> interrupt on change • TMR0 Timer overflow • Data EEPROM write complete
Timer Interrupt void interrupt( void ) // interrupt service routine // call 15 times every second { portb ^= 128; // Blinking RB7 clear_bit( intcon, T0IF ); //clear TMR0 overflow flag } main() { option_reg = 0000111b; //set prescaler to 1:256 trisb = 00000000b; // set RB all as output portb = 11111111b; // turn off all LEDs enable_interrupt( GIE ); enable_interrupt( T0IE ); //enable TMR0 overflow bit while( 1 ); //endless loop }
#include "testboard.h" asm { list p=16F84A __config H'3ff9'} void interrupt( void ) // interrupt service routine // call 15 times every second { portb ^= 128; // Blinking RB7 clear_bit( intcon, T0IF ); //clear TMR0 overflow flag } void main(void) // main program { // starting of the main program option_reg = 0000111b; //set prescaler to 1:256 // for test-board i/o setting, 1=input, 0=output trisa = 00011110b; trisb = 00000000b; // initial porta and portb porta = 00000000b; portb = 11111111b; enable_interrupt( GIE ); enable_interrupt( T0IE ); //enable TMR0 overflow bit music(); }
#include <system.h> #include "test.h" # define blinking_speed 5 // blinking speed from 1(fastest) to 10(slowest) asm { list p=16F84A __config H'3ff9' } char c = 0; // for music on/off toggle char d = 0; void interrupt( void ) { if( switch_status(1) == 1 ) { delay_ms(50); if(switch_status(1)==0){ delay_ms(50); c=!c;} //toggle music } if(d++ == blinking_speed ) { portb = random(); d=0; } clear_bit( intcon, T0IF ); //clear TMR0 overflow flag }
void main(void) { trisa = 00011110b; // assign RA0 as output, RA1 - RA4 as inputs trisb = 00000000b; // assign portb as all output (0 means output, 1 means input) porta = 00000000b; // initial value for porta portb = 11111111b; // initial value for portb option_reg = 0000111b; //set prescaler to 1:256 while( 1 ) //endless loop { enable_interrupt( GIE ); enable_interrupt( T0IE ); //enable TMR0 overflow bit music(); } }
PIC 84 X'mas Tree
PIC 84 X'mas Tree Circuit 3—5V 100 ohms x 8 47K Leds x 8 Ra0 Ra1 Rb 0 ---- 7
Easy-Pic • Started on Dec04 • 1st Phase completed- July05 • Techno-binge – Sep05
Appreciation • Chua Beng Kong • Tan Khee Long • Nancy Low • Francis Li • Dr Lim • Lim Hock Soon • Philip Wong • All of you
16F88 4K memory 10 bit x 7 ADC PWN (CCP) 16F88 USART 2 x 8 bit timer Etc….
Your Technical Support is NEEDED