Sign in

username:

password:



Not a member?

Search avrclub



Search tips

Subscribe to avrclub



avrclub by Keywords

AT90S2313 | AT90S8515 | ATMega | ATmega128 | ECL | FETS | IAR | Keyboard | LCD | STK50 | TMOS | UART

Ads

Discussion Groups

Discussion Groups | AVRclub | Re: [AVR club] keypad question

Atmel AVR Microcontroller discussion group.

keypad question - chrisatwan2000 - Mar 15 12:18:00 2004

I am trying to scan a keypad and display results onto lcd display.
I am using imagecraft compiler for the avr. Does anyone have any
code or know where I can find some.

Thank you,
Chris Atwan




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )


Re: [AVR club] keypad question - jay marante - Mar 15 13:11:00 2004

Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com





(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 15 13:29:00 2004

Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 16 0:12:00 2004

nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 16 11:24:00 2004

Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 16 12:09:00 2004

here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 16 18:04:00 2004

Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 16 19:45:00 2004

i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote:Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 16 19:47:00 2004

i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To





(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 16 19:47:00 2004

i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 16 19:50:00 2004

i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 16 20:59:00 2004

Jay,

I feel bad asking you this after all the help you have given me. What did the hardware setup look like for the keypad to the at90s8515?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 17 5:42:00 2004

here's the pin outs:

keypad (4x3) MCU (Port A)
Pin 1 (2nd col) PA5
Pin 2 (1st row) PA3
Pin 3 (1st col) PA6
Pin 4 (4th row) PA0
Pin 5 (3rd col) PA4
Pin 6 (3rd row) PA1
Pin 7 (2nd row) PA2

you may verify that with an ohmmeter by tappping the pins between the row and the column and pressing the key. example, tapping pin 2 (1st row) with pin 3 (1st col) should be the # 1. ;)

when testing with the AVR simulator, set first PIND2 to high so that it wont generate an interrupt since i enabled the pull-up, so we assume that the MCU will always read "1" on its port when there is no interupt generated. then set PIND2 to low when you want to generate an interrupt. also, together with PIND2, set to high the low nibble of port A. this is because we will read the rows first, and since we also enabled the pull-up resistors. but set one bit to low. setting 1 bit to low means that you pressed that key (say PINA3) if you pressed 1. then continue until when you're about to read the columns. set two bits of the high nibble (from PINA4 to PINA6 -- they are the columns). still we set 1 bit to low (say PINA6 since we pressed # 1) for the MCU to read. and that's it.

anyways, the explanation is on the atmel application notes though the code is written in assemble. yet they are still the same. ;)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

I feel bad asking you this after all the help you have given me. What did the hardware setup look like for the keypad to the at90s8515?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

---------------------------------
Yahoo! Groups Links

To Yahoo! Groups Sponsor

---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - John Johnson - Mar 17 8:05:00 2004

I ran across a novel idea for a keypad encoder using an a/d input on a
ucontroller, something like this:

Vcc
^
|
+-/\/\/-+-/\/\/-+-/\/\/-+
+--|-------|-------|-------|--
| | | | |
> | | | |
< | | | |
| | | | |
+--|-------|-------|-------|--
| | | | |
> | | | |
< | | | |
| | | | |
+--|-------|-------|-------|--
| | | | |
> | | | |
< | | | |
| | | | |
out ---+--|-------|-------|-------|--
|
>
< (these are resistors too)
|
V
Gnd

A keypad switch is connected where each vertical and horizontal line
cross. You can probably Google and find more/better schematics.

Regards,
JJ On Wednesday, Mar 17, 2004, at 04:42 US/Eastern, jay marante wrote:

> here's the pin outs:
>
> keypad (4x3) MCU (Port A)
> Pin 1 (2nd col) PA5
> Pin 2 (1st row) PA3
> Pin 3 (1st col) PA6
> Pin 4 (4th row) PA0
> Pin 5 (3rd col) PA4
> Pin 6 (3rd row) PA1
> Pin 7 (2nd row) PA2
>
> you may verify that with an ohmmeter by tappping the pins between the
> row and the column and pressing the key. example, tapping pin 2 (1st
> row) with pin 3 (1st col) should be the # 1. ;)
>
> when testing with the AVR simulator, set first PIND2 to high so that
> it wont generate an interrupt since i enabled the pull-up, so we
> assume that the MCU will always read "1" on its port when there is no
> interupt generated. then set PIND2 to low when you want to generate an
> interrupt. also, together with PIND2, set to high the low nibble of
> port A. this is because we will read the rows first, and since we also
> enabled the pull-up resistors. but set one bit to low. setting 1 bit
> to low means that you pressed that key (say PINA3) if you pressed 1.
> then continue until when you're about to read the columns. set two
> bits of the high nibble (from PINA4 to PINA6 -- they are the columns).
> still we set 1 bit to low (say PINA6 since we pressed # 1) for the MCU
> to read. and that's it.
>
> anyways, the explanation is on the atmel application notes though the
> code is written in assemble. yet they are still the same. ;)
>
> -jay
>
> chris atwan <chrisatwan2000@chri...> wrote:
> Jay,
>
> I feel bad asking you this after all the help you have given me. What
> did the hardware setup look like for the keypad to the at90s8515?
>
> Chris Atwan
>
> jay marante <jaythesis@jayt...> wrote:
> i used the latest version of the ICCAVR.
>
> chris atwan <chrisatwan2000@chri...> wrote: Jay,
>
> Was this written in Codevision?
>
> Chris
>
> jay marante <jaythesis@jayt...> wrote:
> here, try this.
>
> i used a 4x3 keypad and 7.3728MHz of crystal.
> this was my first program in AVR actually. :-)
> good luck.
>
> -jay > chris atwan <chrisatwan2000@chri...> wrote:
> Jay,
>
> Well I would be interested in seeing it if you can find it.
>
> Chris Atwan
>
> jay marante <jaythesis@jayt...> wrote:
> nahh... i think it's in assembly.
>
> i have 1 before using the AT90S8515 but i think i lost it. :)
>
> -jay
>
> chris atwan <chrisatwan2000@chri...> wrote:
> Jay,
>
> Is this example using imagecraft?
>
> Chris Atwan
>
> jay marante <jaythesis@jayt...> wrote:
> Theres an application notes at the atmel website. -jay
> --- chrisatwan2000@chri...
> <chrisatwan2000@chri...> wrote:
>> I am trying to scan a keypad and display results
> onto lcd display.
>> I am using imagecraft compiler for the avr. Does
> anyone have any
>> code or know where I can find some.
>>
>> Thank you,
>> Chris Atwan
> > __________________________________
> ">http://mail.yahoo.com > ---------------------------------
> Yahoo! Groups Links
>
> To >
> ---------------------------------
> Yahoo! Groups Links
>
> To >
> ---------------------------------
> Yahoo! Groups Links
>
> To >
> ---------------------------------
> Yahoo! Groups Links
>
> To >
>
> #include <io8515v.h>
>
> /
> ***********************************************************************
> *********
> * Interrupt Vectors Declarations
> ***********************************************************************
> *********/
> #pragma interrupt_handler VECInt0:2 /* External Interrupt
> Request 0 */
> #pragma interrupt_handler VECInt1:3 /* External Interrput
> Request 1 */
> #pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture
> Event */
> #pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare
> Match A */
> #pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare
> Match B */
> #pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow
> */
> #pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow
> */
> #pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete
> */
> #pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete
> */
> #pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register
> Empty */
> #pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete
> */
> #pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator
> */ > /
> ***********************************************************************
> *********
> * Function prototypes
> ***********************************************************************
> *********/
> void main (void);
> void VECInt0 (void);
> void VECInt1 (void);
> void VECTmr1_Capt (void);
> void VECTmr1_CompA (void);
> void VECTmr1_CompB (void);
> void VECTmr1_Ovf (void);
> void VECTmr0_Ovf (void);
> void VECSPI_STC (void);
> void VECUART_RX (void);
> void VECUART_UDRE (void);
> void VECUART_TX (void);
> void VECAna_Comp (void);
>
> void keypadinit (void);
> void delay (void);
>
> #define PORTDIR DDRA
>
> /*
> ***********************************************************************
> *********
> * Main Program
> ***********************************************************************
> *********
> */
> void main (void)
> {
> SPH = 0x02; //initialize stack
> pointer high byte
> SPL = 0x5F; //initialize stack
> pointer low byte
> SREG = 0x80; //set global
> interrupt enable
> DDRD = 0xFB; //set PORTD pin 2 as
> input, rest output
> PORTD = 0x04; //set PIN2 pull-up
> resistor
> GIMSK = 0x40; //set external
> interrupt 0 enable
> MCUCR = 0x00; //set external
> interrupt 0 sense control to low level
> TIMSK = 0x80; //set timer/counter
> 1 interrupt overflow enable
>
> keypadinit(); //initialize the
> keypad
>
> for(;;) //infinite loop
> {}
> } > void VECInt0 (void)
> {
> unsigned char key;
> unsigned char value;
>
> value = ~(PINA|0xF0); // 0000iiii; get row
> pressed
> if (value == 1) key = 9; //if 4th row
> else if (value == 2) key = 6; //if 3rd row
> else if (value == 4) key = 3; //if 2nd row
> else if (value == 8) key = 0; //if 1st row
>
> /************** swap nybbles *****************/
> PORTDIR |= 0x8F; // 1XXX1111
> PORTDIR &= 0x8F; //set PORTB nybbles
> for keypad, 10001111
> PORTA |= 0x70; // X111XXXX
> PORTA &= 0x70; //set PORTC outputs
> and pull-ups, 01110000
>
> delay(); //delay to settle
> the pins
> value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
> if (value == 0x01) key += 3; //if 3rd column
> else if (value == 0x02) key += 2; //if 2nd column
> else if (value == 0x04) key += 1; //if 1st column
>
> keypadinit(); //reset PORTA
> direction
>
> /*********** this part is for debouncing ****************/
> GIMSK = 0x00; //disable external
> interrupt 0
> TCNT1 = 0xFA60; //start count from
> 64096 to obtain
> //timer
> overflow of 0.2 second
> TCCR1B = 0x05; //prescaler = ck/1024
> TIMSK |= 0x80; //set timer/counter 1
> interrupt overflow enable
> }
> void VECInt1 (void)
> {}
> void VECTmr1_Capt (void)
> {}
> void VECTmr1_CompA (void)
> {}
> void VECTmr1_CompB (void)
> {}
> void VECTmr1_Ovf (void)
> {
> GIMSK |= 0x40; //set external
> interrupt enable
> TCCR1B = 0x00; //disable timer
> TIMSK &= 0x7F; //set timer/counter
> interrupt disable
> GIFR = 0x00; //set external
> interrupt flag to 0
> }
> void VECTmr0_Ovf (void)
> {}
> void VECSPI_STC (void)
> {}
> void VECUART_RX (void)
> {}
> void VECUART_UDRE (void)
> {}
> void VECUART_TX (void)
> {}
> void VECAna_Comp (void)
> {} > void keypadinit (void)
> {
> PORTDIR |= 0xF0; // 1111XXXX
> PORTDIR &= 0xF0; //set PORTA nybbles
> for keypad, 11110000
> PORTA |= 0x0F; // XXXX1111
> PORTA &= 0x0F; //set PORTA outputs and
> pull-ups, 00001111
> } > void delay (void)
> {
> unsigned i;
> for (i = 0; i < 255; i++)
> {}
> } >
> [Non-text portions of this message have been removed] >
> ---------------------------------
> Yahoo! Groups Links
>
> To >
> ---------------------------------
> Yahoo! Groups Links
>
> To >
>
> ---------------------------------
> Yahoo! Groups Links
>
> To > Yahoo! Groups Sponsor
>
> ---------------------------------
> Yahoo! Groups Links
>
> To >
>
> Yahoo! Groups Links





(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 17 11:06:00 2004

Jay,

Should this code be able to change for a 4x4 keypad? I need 16 keys for my toy.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
here's the pin outs:

keypad (4x3) MCU (Port A)
Pin 1 (2nd col) PA5
Pin 2 (1st row) PA3
Pin 3 (1st col) PA6
Pin 4 (4th row) PA0
Pin 5 (3rd col) PA4
Pin 6 (3rd row) PA1
Pin 7 (2nd row) PA2

you may verify that with an ohmmeter by tappping the pins between the row and the column and pressing the key. example, tapping pin 2 (1st row) with pin 3 (1st col) should be the # 1. ;)

when testing with the AVR simulator, set first PIND2 to high so that it wont generate an interrupt since i enabled the pull-up, so we assume that the MCU will always read "1" on its port when there is no interupt generated. then set PIND2 to low when you want to generate an interrupt. also, together with PIND2, set to high the low nibble of port A. this is because we will read the rows first, and since we also enabled the pull-up resistors. but set one bit to low. setting 1 bit to low means that you pressed that key (say PINA3) if you pressed 1. then continue until when you're about to read the columns. set two bits of the high nibble (from PINA4 to PINA6 -- they are the columns). still we set 1 bit to low (say PINA6 since we pressed # 1) for the MCU to read. and that's it.

anyways, the explanation is on the atmel application notes though the code is written in assemble. yet they are still the same. ;)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

I feel bad asking you this after all the help you have given me. What did the hardware setup look like for the keypad to the at90s8515?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

---------------------------------
Yahoo! Groups Links

To Yahoo! Groups Sponsor

---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - jay marante - Mar 17 11:25:00 2004

yeah... you'll just have to use the last pin (PINA7) for the last column. maybe you'll have to adjust the connections since i don't know exactly where the last pin is located at the keypad.

note: use the lower nibble of the port for the rows and the high nibble for the columns.

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Should this code be able to change for a 4x4 keypad? I need 16 keys for my toy.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
here's the pin outs:

keypad (4x3) MCU (Port A)
Pin 1 (2nd col) PA5
Pin 2 (1st row) PA3
Pin 3 (1st col) PA6
Pin 4 (4th row) PA0
Pin 5 (3rd col) PA4
Pin 6 (3rd row) PA1
Pin 7 (2nd row) PA2

you may verify that with an ohmmeter by tappping the pins between the row and the column and pressing the key. example, tapping pin 2 (1st row) with pin 3 (1st col) should be the # 1. ;)

when testing with the AVR simulator, set first PIND2 to high so that it wont generate an interrupt since i enabled the pull-up, so we assume that the MCU will always read "1" on its port when there is no interupt generated. then set PIND2 to low when you want to generate an interrupt. also, together with PIND2, set to high the low nibble of port A. this is because we will read the rows first, and since we also enabled the pull-up resistors. but set one bit to low. setting 1 bit to low means that you pressed that key (say PINA3) if you pressed 1. then continue until when you're about to read the columns. set two bits of the high nibble (from PINA4 to PINA6 -- they are the columns). still we set 1 bit to low (say PINA6 since we pressed # 1) for the MCU to read. and that's it.

anyways, the explanation is on the atmel application notes though the code is written in assemble. yet they are still the same. ;)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

I feel bad asking you this after all the help you have given me. What did the hardware setup look like for the keypad to the at90s8515?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

---------------------------------
Yahoo! Groups Links

To Yahoo! Groups Sponsor

---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 17 14:27:00 2004

Jay,

I will try this, thank you for the help. Sorry about bothering you so much on this problem.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
yeah... you'll just have to use the last pin (PINA7) for the last column. maybe you'll have to adjust the connections since i don't know exactly where the last pin is located at the keypad.

note: use the lower nibble of the port for the rows and the high nibble for the columns.

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Should this code be able to change for a 4x4 keypad? I need 16 keys for my toy.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
here's the pin outs:

keypad (4x3) MCU (Port A)
Pin 1 (2nd col) PA5
Pin 2 (1st row) PA3
Pin 3 (1st col) PA6
Pin 4 (4th row) PA0
Pin 5 (3rd col) PA4
Pin 6 (3rd row) PA1
Pin 7 (2nd row) PA2

you may verify that with an ohmmeter by tappping the pins between the row and the column and pressing the key. example, tapping pin 2 (1st row) with pin 3 (1st col) should be the # 1. ;)

when testing with the AVR simulator, set first PIND2 to high so that it wont generate an interrupt since i enabled the pull-up, so we assume that the MCU will always read "1" on its port when there is no interupt generated. then set PIND2 to low when you want to generate an interrupt. also, together with PIND2, set to high the low nibble of port A. this is because we will read the rows first, and since we also enabled the pull-up resistors. but set one bit to low. setting 1 bit to low means that you pressed that key (say PINA3) if you pressed 1. then continue until when you're about to read the columns. set two bits of the high nibble (from PINA4 to PINA6 -- they are the columns). still we set 1 bit to low (say PINA6 since we pressed # 1) for the MCU to read. and that's it.

anyways, the explanation is on the atmel application notes though the code is written in assemble. yet they are still the same. ;)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

I feel bad asking you this after all the help you have given me. What did the hardware setup look like for the keypad to the at90s8515?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

---------------------------------
Yahoo! Groups Links

To Yahoo! Groups Sponsor

---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )

Re: [AVR club] keypad question - chris atwan - Mar 17 19:34:00 2004

Jay,

The atmel example I was trying to follow with the keypad is the one that uses 4 diodes for the 4 columns. Is this ok with the code you sent me?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
yeah... you'll just have to use the last pin (PINA7) for the last column. maybe you'll have to adjust the connections since i don't know exactly where the last pin is located at the keypad.

note: use the lower nibble of the port for the rows and the high nibble for the columns.

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Should this code be able to change for a 4x4 keypad? I need 16 keys for my toy.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
here's the pin outs:

keypad (4x3) MCU (Port A)
Pin 1 (2nd col) PA5
Pin 2 (1st row) PA3
Pin 3 (1st col) PA6
Pin 4 (4th row) PA0
Pin 5 (3rd col) PA4
Pin 6 (3rd row) PA1
Pin 7 (2nd row) PA2

you may verify that with an ohmmeter by tappping the pins between the row and the column and pressing the key. example, tapping pin 2 (1st row) with pin 3 (1st col) should be the # 1. ;)

when testing with the AVR simulator, set first PIND2 to high so that it wont generate an interrupt since i enabled the pull-up, so we assume that the MCU will always read "1" on its port when there is no interupt generated. then set PIND2 to low when you want to generate an interrupt. also, together with PIND2, set to high the low nibble of port A. this is because we will read the rows first, and since we also enabled the pull-up resistors. but set one bit to low. setting 1 bit to low means that you pressed that key (say PINA3) if you pressed 1. then continue until when you're about to read the columns. set two bits of the high nibble (from PINA4 to PINA6 -- they are the columns). still we set 1 bit to low (say PINA6 since we pressed # 1) for the MCU to read. and that's it.

anyways, the explanation is on the atmel application notes though the code is written in assemble. yet they are still the same. ;)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

I feel bad asking you this after all the help you have given me. What did the hardware setup look like for the keypad to the at90s8515?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
i used the latest version of the ICCAVR.

chris atwan <chrisatwan2000@chri...> wrote: Jay,

Was this written in Codevision?

Chris

jay marante <jaythesis@jayt...> wrote:
here, try this.

i used a 4x3 keypad and 7.3728MHz of crystal.
this was my first program in AVR actually. :-)
good luck.

-jay chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Well I would be interested in seeing it if you can find it.

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
nahh... i think it's in assembly.

i have 1 before using the AT90S8515 but i think i lost it. :)

-jay

chris atwan <chrisatwan2000@chri...> wrote:
Jay,

Is this example using imagecraft?

Chris Atwan

jay marante <jaythesis@jayt...> wrote:
Theres an application notes at the atmel website. -jay
--- chrisatwan2000@chri...
<chrisatwan2000@chri...> wrote:
> I am trying to scan a keypad and display results
onto lcd display.
> I am using imagecraft compiler for the avr. Does
anyone have any
> code or know where I can find some.
>
> Thank you,
> Chris Atwan
__________________________________
">http://mail.yahoo.com ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

#include <io8515v.h>

/********************************************************************************
* Interrupt Vectors Declarations
********************************************************************************/
#pragma interrupt_handler VECInt0:2 /* External Interrupt Request 0 */
#pragma interrupt_handler VECInt1:3 /* External Interrput Request 1 */
#pragma interrupt_handler VECTmr1_Capt:4 /* Timer/Counter 1 Capture Event */
#pragma interrupt_handler VECTmr1_CompA:5 /* Timer/Counter 1 Compare Match A */
#pragma interrupt_handler VECTmr1_CompB:6 /* Timer/Counter 1 Compare Match B */
#pragma interrupt_handler VECTmr1_Ovf:7 /* Timer/Counter 1 Overflow */
#pragma interrupt_handler VECTmr0_Ovf:8 /* Timer/Counter 0 Overflow */
#pragma interrupt_handler VECSPI_STC:9 /* Serial Transfer Complete */
#pragma interrupt_handler VECUART_RX:10 /* UART, RX Complete */
#pragma interrupt_handler VECUART_UDRE:11 /* UART, Data Register Empty */
#pragma interrupt_handler VECUART_TX:12 /* UART, TX Complete */
#pragma interrupt_handler VECAna_Comp:13 /* Analog Comparator */ /********************************************************************************
* Function prototypes
********************************************************************************/
void main (void);
void VECInt0 (void);
void VECInt1 (void);
void VECTmr1_Capt (void);
void VECTmr1_CompA (void);
void VECTmr1_CompB (void);
void VECTmr1_Ovf (void);
void VECTmr0_Ovf (void);
void VECSPI_STC (void);
void VECUART_RX (void);
void VECUART_UDRE (void);
void VECUART_TX (void);
void VECAna_Comp (void);

void keypadinit (void);
void delay (void);

#define PORTDIR DDRA

/*
********************************************************************************
* Main Program
********************************************************************************
*/
void main (void)
{
SPH = 0x02; //initialize stack pointer high byte
SPL = 0x5F; //initialize stack pointer low byte
SREG = 0x80; //set global interrupt enable
DDRD = 0xFB; //set PORTD pin 2 as input, rest output
PORTD = 0x04; //set PIN2 pull-up resistor
GIMSK = 0x40; //set external interrupt 0 enable
MCUCR = 0x00; //set external interrupt 0 sense control to low level
TIMSK = 0x80; //set timer/counter 1 interrupt overflow enable

keypadinit(); //initialize the keypad

for(;;) //infinite loop
{}
} void VECInt0 (void)
{
unsigned char key;
unsigned char value;

value = ~(PINA|0xF0); // 0000iiii; get row pressed
if (value == 1) key = 9; //if 4th row
else if (value == 2) key = 6; //if 3rd row
else if (value == 4) key = 3; //if 2nd row
else if (value == 8) key = 0; //if 1st row

/************** swap nybbles *****************/
PORTDIR |= 0x8F; // 1XXX1111
PORTDIR &= 0x8F; //set PORTB nybbles for keypad, 10001111
PORTA |= 0x70; // X111XXXX
PORTA &= 0x70; //set PORTC outputs and pull-ups, 01110000

delay(); //delay to settle the pins
value = ~((PINA>>4)|0xF8); // 0iii0000; ge column pressed
if (value == 0x01) key += 3; //if 3rd column
else if (value == 0x02) key += 2; //if 2nd column
else if (value == 0x04) key += 1; //if 1st column

keypadinit(); //reset PORTA direction

/*********** this part is for debouncing ****************/
GIMSK = 0x00; //disable external interrupt 0
TCNT1 = 0xFA60; //start count from 64096 to obtain
//timer overflow of 0.2 second
TCCR1B = 0x05; //prescaler = ck/1024
TIMSK |= 0x80; //set timer/counter 1 interrupt overflow enable
}
void VECInt1 (void)
{}
void VECTmr1_Capt (void)
{}
void VECTmr1_CompA (void)
{}
void VECTmr1_CompB (void)
{}
void VECTmr1_Ovf (void)
{
GIMSK |= 0x40; //set external interrupt enable
TCCR1B = 0x00; //disable timer
TIMSK &= 0x7F; //set timer/counter interrupt disable
GIFR = 0x00; //set external interrupt flag to 0
}
void VECTmr0_Ovf (void)
{}
void VECSPI_STC (void)
{}
void VECUART_RX (void)
{}
void VECUART_UDRE (void)
{}
void VECUART_TX (void)
{}
void VECAna_Comp (void)
{} void keypadinit (void)
{
PORTDIR |= 0xF0; // 1111XXXX
PORTDIR &= 0xF0; //set PORTA nybbles for keypad, 11110000
PORTA |= 0x0F; // XXXX1111
PORTA &= 0x0F; //set PORTA outputs and pull-ups, 00001111
} void delay (void)
{
unsigned i;
for (i = 0; i < 255; i++)
{}
}
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To

---------------------------------
Yahoo! Groups Links

To Yahoo! Groups Sponsor

---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links

To Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )