cancel
Showing results for 
Search instead for 
Did you mean: 

ADC+keyboard+interrupt

sany_as
Associate II
Posted on October 03, 2006 at 04:28

ADC+keyboard+interrupt

16 REPLIES 16
sany_as
Associate II
Posted on September 20, 2006 at 16:25

Hello all!!!

I am using STR710FZ26 for developing my programs.I am facing problems

in using interrupts. As an example i tried the following code

for ADC.I am planning to implement a keypad (30 keys) using the circuit

diagram recommended by ST in their application note AN1809.

However i used a pull up resistor.(is it not recommended)

When i use the code given by ST, the values obtained for each key

varies drastically.Hence i decided to use interrupts.But although

the above programme gets build, its not entering the interrupt routine.

CAN ANY ONE PLEASE HELP ME OUT?

#include ''71x_lib.h''

#include ''LCD.h''

#include ''eic.h''

u16 data=0;

void Main(void)

{

int i;

#ifdef DEBUG

debug();

#endif

LCD_Init();

// Configure the used analog input(P1.1) to HI_AIN_TRI

GPIO_Config(GPIO1, 0x0002, GPIO_HI_AIN_TRI);

ADC12_Init(); //ADC12->CSR = 0x00; ADC12->CPR = 0x01;

ADC12_PrescalerConfig(500);

ADC12_ModeConfig(ADC12_SINGLE);

ADC12_ChannelSelect(ADC12_CHANNEL1);

ADC12_ITConfig(ENABLE);

ADC12_ConversionStart();

EIC_Init();

//EIC->IER |= 0x0001 << ADC_IRQChannel;

EIC_IRQChannelConfig(ADC_IRQChannel, ENABLE);

//EIC->SIR[ADC_IRQChannel] = (EIC->SIR[ADC_IRQChannel]&0xFFFF0000) |

(u16)Priority & 0x000F;

EIC_IRQChannelPriorityConfig(ADC_IRQChannel,1);

//EIC->ICR |= 0x0001

EIC_IRQConfig(ENABLE);

while(1)

{

LCD_Goto(0, 0);

LCD_Printf(''ADC: %d '',data);

}

}

/*the routine used for interrupt :included in 71x_it.c*/

/*volatile u16 data;

void ADC12_IRQHandler(void)

{

data= ADC12_ConversionValue(ADC12_CHANNEL0);

ADC12->CSR &= ~ADC12_DA0;

} */

DO ANYONE HAS AN EXAMPLE CODE that is running for sure, and what is the problem with this code???

KINDLY HELP....

Regards

And thanks in advance

hichem2
Associate II
Posted on September 21, 2006 at 06:19

Hello,

With the STR71x software library V3.1 you can find an example of the ADC (interrupt example).

This example demonstrates how to use the ADC12 in single channel conversion mode and switch on a led connected to Port 0 according to the conversion result using the ADC12 interrupt service routine.

And it work sure on the MB393B ST board.

Regards,

Hich

ajsndd
Associate II
Posted on September 21, 2006 at 11:11

Thank you very much Mr. Hichem.

I'll try out this ex and get back to you..

Once again thanks for your reference.

Regards

Sany

sany_as
Associate II
Posted on September 22, 2006 at 09:17

Sir i am using a keyboard with a 1K pull up resistor and supply of 2.5 vold to drive this keyboard. There are 30 keys and the resistors are of 10 ohm each.However the voltage difference between each key press is 30 to 40 mV, is it correct to do so.

Kindly reply.

Thanks and regrds

Sany

hichem2
Associate II
Posted on September 25, 2006 at 06:30

Hello Sany,

There is an application note (AN 1809) available on ST web page on the following link:

http://mcu.st.com/mcu/modules.php?name=mcu&file=familiesdocs&fam=86.

Really it is not updated since Feb 2005 but may it can give you and idea concerning your application.

With best regards,

Hich

sany_as
Associate II
Posted on September 26, 2006 at 03:15

I am using the same principle,but the difference is that the resistors i chose is of same 10 ohm.I am dropping the voltage across each key using a series of 10 ohm resistors rather than 56,68,82 ohm etc as mentioned in the application note.But i am not getting accurate results.If the keys are pressedonce it gives a particular code but when pressed for many times continuously the values vary drastically.I decided to use interrupts for better performance but ''failure''. This is one of the major portion of my project and i am stuck with this also i am not in a position to dedicated more than one pin for a keyboard.

My future development is stuck up.I WANT TO SOLVE THIS PROBLEM AS SOON AS POSSIBLE.hOPE YOU CAN HELP.

Regards and Thanks in advance.

Sany

hichem2
Associate II
Posted on September 26, 2006 at 10:59

Hi Sany,

I have another suggestion.

Could you please verify if the interrupt vectors are mapped at address 0x00000000?

With regards.

Hich

ajsndd
Associate II
Posted on September 27, 2006 at 01:34

did u mean the initialisation of EIC in 71x_init.s??

well its declared as

.equ EIC_Base_addr, 0xFFFFF800/* EIC base address */

i hope its correct.

Sir is there any fault in the code i mailed on my first querry.Or is it the harware thats creating problem???

Please help..

Regards

Sany

hichem2
Associate II
Posted on September 27, 2006 at 06:58

Hello,

Could you tell me which tool-set and which board you use to develop your example?

Do you load you project in FLASH or RAM, What is the boot pin setting?

BOOTCR 16bit register allows you to know which memory is mapped to address 0, BOOTCR address is 0xA0000050

0xXXX0 -> FLASH

0xXXX2 -> RAM

0xXXX3 -> EMI bank0

regards,

Hich