SW006010 Microchip Technology, SW006010 Datasheet - Page 38

no-image

SW006010

Manufacturer Part Number
SW006010
Description
MPLAB 17C SOFTWARE
Manufacturer
Microchip Technology
Datasheets

Specifications of SW006010

Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC17C
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
MPLAB®
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
MPLAB
apRNOVS^-page 34
C17 C Compiler Libraries
2.7.2
unsigned char Key;
void PIV_ISR(void)
{
}
void main(void)
{
#include<p17C756.h>
#include<int16.h>
#include<portb16.h>
if(PIR1bits.RBIF)
{
}
unsigned char PressedKey;
Install_PIV(PIV_ISR); // install peripheral
DDRB = 0xF0;
Key = 0x00;
PORTB = PORTB;
PIR1bits.RBIF = 0; // clear RBIF to ensure no interrupt
// enable PORTB interrupt on change
OpenPORTB(PORTB_CHANGE_INT_ON);
EnablePullups();
Enable();
while(1)
{
Key = ~(PORTB & 0xF0);
PIR1bits.RBIF = 0;
{
DDRB = 0x0F;
PORTB = 0x00;
Key += ~(PORTB & 0x0F); // add in scan column
while(Key==0x00);
switch(Key)
Example of Use
case 0x11:
case 0x12:
case 0x14:
case 0x18:
PressedKey = ’1’;
break;
PressedKey = ’2’;
break;
PressedKey = ’3’;
break;
PressedKey = ’4’;
break;
// set lower nibble to output
// upper nibble to input to scan row
// reset key scan register
// read PORTB to clear mismatch
// enable internal pullups
// enable global interrupts
// interrupt vector
// ensure PORTB interrupt
// got us here
// keep track of scan row
// switch I/O drive to
// scan column
// reset interrupt flag
 2002 Microchip Technology Inc.

Related parts for SW006010