1 / 13

16F84A Interrupt

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 {

Télécharger la présentation

16F84A Interrupt

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 16F84A Interrupt • 4 interrupt sources: • External Rb0 interrupt pin. • Portb<7:4> interrupt on change • TMR0 Timer overflow • Data EEPROM write complete

  2. 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 }

  3. #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(); }

  4. #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 }

  5. 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(); } }

  6. PIC 84 X'mas Tree

  7. PIC 84 X'mas Tree Circuit 3—5V 100 ohms x 8 47K Leds x 8 Ra0 Ra1 Rb 0 ---- 7

  8. Easy-Pic • Started on Dec04 • 1st Phase completed- July05 • Techno-binge – Sep05

  9. Appreciation • Chua Beng Kong • Tan Khee Long • Nancy Low • Francis Li • Dr Lim • Lim Hock Soon • Philip Wong • All of you

  10. PIC Interest Group

  11. Future Development

  12. 16F88 4K memory 10 bit x 7 ADC PWN (CCP) 16F88 USART 2 x 8 bit timer Etc….

  13. Your Technical Support is NEEDED

More Related