2001 Microchip Technology Inc.
DS39024B-page 67
SWITCH.C
Description
8.6
SWITCH.C
Source Code Listing
//****************************************************
//* SWITCH.C
//****************************************************
//* Rodger Richey
//* Principal Applications Engineer
//* Microchip Technology Incorporated
//****************************************************
//* 2 December 1998
//* Compiled using MPLAB C17 C Compiler V2.20
//****************************************************
//* This program toggles the state of the memory
//* mapped LEDs when the corresponding memory mapped
//* switch is pressed.
//****************************************************
//* Uses an oscillator of 16MHz
//****************************************************
#include <p17c756.h>
#include <delays.h>
void main(void)
{
unsigned int LEDbuf;
unsigned int SWTbuf;
unsigned int TEMPbuf;
unsigned int Temp;
rom int *LEDptr;
rom int *SWTptr;
// Initialize pointers to the memory mapped device
LEDptr = (rom int *)0xfffd;
SWTptr = (rom int *)0xfffc;
// Initialize the LEDs and other variables
*LEDptr = 0x00ff;
LEDbuf = 0x00ff;
SWTbuf = 0x00ff;
while(1)
{
// Read the state of the switches
TEMPbuf = *SWTptr & 0x00ff;
// Determine what switch states have changed
Temp = TEMPbuf ^ SWTbuf;
// If a switch state has changed and the change
// was a switch press
if(Temp && TEMPbuf != 0x00ff)
{
// If need to toggle LED low
if(Temp&LEDbuf)
// Mask off desired
LED
LEDbuf &= ~Temp;
// Else need to toggle LED high
Содержание Picdem 17
Страница 1: ...PICDEM 17 DEMONSTRATION BOARD USER S GUIDE 2001 Microchip Technology Inc DS39024B ...
Страница 19: ... 2001 Microchip Technology Inc DS39024B page 13 Using the PICDEM 17 Monitor Figure 2 5 Running Diagnostics ...
Страница 24: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 18 2001 Microchip Technology Inc NOTES ...
Страница 28: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 22 2001 Microchip Technology Inc NOTES ...
Страница 40: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 34 2001 Microchip Technology Inc NOTES ...
Страница 62: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 56 2001 Microchip Technology Inc NOTES ...
Страница 80: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 74 2001 Microchip Technology Inc NOTES ...
Страница 82: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 76 2001 Microchip Technology Inc A 1 SCHEMATIC 1 ...
Страница 83: ... 2001 Microchip Technology Inc DS39024B page 77 PICDEM 17 Demonstration Board Schematics A 2 SCHEMATIC 2 ...
Страница 84: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 78 2001 Microchip Technology Inc A 3 SCHEMATIC 3 ...
Страница 85: ... 2001 Microchip Technology Inc DS39024B page 79 PICDEM 17 Demonstration Board Schematics A 4 SCHEMATIC 4 ...
Страница 86: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 80 2001 Microchip Technology Inc NOTES ...
Страница 90: ...PICDEM 17 Demonstration Board User s Guide DS39024B page 84 2001 Microchip Technology Inc NOTES ...
Страница 91: ... 2001 Microchip Technology Inc DS39024B page 85 Floppy Disk Contents NOTES ...