Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
PIC Microcontroller, Switch Hello World, PIC16F1823

PIC Microcontroller, Switch Hello World, PIC16F1823

Ratings: (0)|Views: 312 |Likes:
Published by Nolan Manteufel

Assembly code example of using interrupts to respond to a switch on PIC16F1823 PORTA and controlling an LED connected on PORTC. The PIC microcontroller is placed in SLEEP mode when it is finished changing the LED. This reduces the power being consumed by the microcontroller. The Interrupt on Change (IOC) PORTA interrupt wakes the micro from sleep.

Assembly code example of using interrupts to respond to a switch on PIC16F1823 PORTA and controlling an LED connected on PORTC. The PIC microcontroller is placed in SLEEP mode when it is finished changing the LED. This reduces the power being consumed by the microcontroller. The Interrupt on Change (IOC) PORTA interrupt wakes the micro from sleep.

More info:

Published by: Nolan Manteufel on Nov 11, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

09/17/2013

pdf

text

original

 
;******************************************************************************;; Filename: I2C.asm; Date: November 6, 2012; File Version: 1.0;; Author: Nolan Manteufel;*; Company: University of Texas at San Antonio; URL: www.utsa.edu/engineering;*;******************************************************************************list p=16f1823 ; list directive to define processor#include <p16f1823.inc> ; processor specific variable definitions;------------------------------------------------------------------------------; CONFIGURATION WORD SETUP;------------------------------------------------------------------------------ __CONFIG _CONFIG1, _CP_OFF & _WDTE_OFF & _FOSC_INTOSC & _PWRTE_OFF & _MCLRE_ON & _CLKOUTEN_OFF __CONFIG _CONFIG2, _LVP_OFF & _BORV_HI & _STVREN_ON & _WRT_OFF;------------------------------------------------------------------------------; RAM;------------------------------------------------------------------------------CBLOCK 0x20; Location of RAMx; Used for pointless mathENDC;;------------------------------------------------------------------------------; DEFINITIONS;------------------------------------------------------------------------------LEDEQU0x05; LED location on PORTCSWITCHEQU0x05; Switch location on PORTA;------------------------------------------------------------------------------; RESET VECTOR;------------------------------------------------------------------------------ORG 0x0000; Reset vectornop;goto START;;------------------------------------------------------------------------------; INTERRUPT SERVICE ROUTINE;------------------------------------------------------------------------------ORG 0x0004;nop;btfscINTCON, IOCIF;gotoswitch_isr; set = Switch changedconfig_and_return; clear = Not switchmovlwb'00001000';movwfINTCON;retfie;;-------------------------------------------------------------------------------; Switch Interupt Service Routine
 
;-------------------------------------------------------------------------------switch_isr;bcfINTCON, IOCIF;banksel IOCAF;btfssIOCAF, SWITCH;goto config_and_return; clear = wasnt the switchbanksel PORTA; set = was the switchbtfssPORTA, SWITCH;gotoled_off;gotoled_on;led_off;bankselPORTC;bcfPORTC, LED;goto config_and_return;led_on;bankselPORTC;bsfPORTC, LED;goto config_and_return;;------------------------------------------------------------------------------; MAIN PROGRAM;------------------------------------------------------------------------------START;clrw;;-------------------------------------------------------------------------------; Configuring PORTA for Switch, see page 126 and 135 of PIC16F1823 datasheet;-------------------------------------------------------------------------------banksel PORTA;bcfPORTA, SWITCH;banksel LATA;bcfLATA, SWITCH;banksel TRISA;bsfTRISA, SWITCH;banksel IOCAP;bsfIOCAP, SWITCH;banksel IOCAN;bsfIOCAN, SWITCH;;-------------------------------------------------------------------------------; Configuring PORTC for LED, see page 129 of PIC16F1823 datasheet;-------------------------------------------------------------------------------config_PORTCbanksel PORTCbcf PORTC, LEDbanksel LATCbcf LATC, LEDbanksel ANSELCclrf ANSELCbankselTRISCbcfTRISC, LED;-------------------------------------------------------------------------------; Set LED output to match switch input;-------------------------------------------------------------------------------banksel PORTA; set = was the switchbtfssPORTA, SWITCH;gotoled_off_2;gotoled_on_2;led_off_2;

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->