PDA

View Full Version : Help! i/o and interrupt pin selection in AT91SAM7x512


chintan
Feb 24, 2008, 12:49 AM
hi,
To all,

I m working on AT91SAM7x512 and ARM is new for me and its datasheet is quite confusing and with less example of Initialization in C code. so any one can give me suggestion how to assign interrupt on change on I/O pin.

IT is confusing in datasheet because there are total 32 interrupt available and also written interrupt on change is available for each i/o pin but there are two Parallel I/O controller with 31 pins it means total 62 pins available for interrupt so how to assign interrupt on particular I/o pin using register and how to write a interrupt service routine as we can write for any interrupt in 8 bit controller.

if any suggestion or any other help is possible than most welcome
Thanks in advance for reply.
_________________
Chintan
R&D Engineer,
Trinity Energy Systems Pvt. Ltd.,
Baroda.

AndyKunz
Feb 25, 2008, 09:30 AM
Hi Chintan,

I work with this same chip (and X256) for about 2 years now. Can you give me the full part number (including -ES if it has it) and date code on your device please? I am working an issue with Atmel and need to get as many date codes as possible.

As for interrupt sources, you need the Atmel file AT91SAM7X256.H or ...512.H to make this work.

Typically, what you do is:

// Set vector to the ISR
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_PIOA] = (AT91_REG)my_pioa_isr;

// Set IRQ mode (falling edge) and priority
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_PIOA] = AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE | (AT91C_AIC_PRIOR_LOWEST + 3);

// Enable this interrupt in AIC
*AT91C_AIC_IECR = (1 << AT91C_ID_PIOA);

In your ISR, you need to check what bit caused the interrupt. Sorry, but you don't get an individual interrupt vector for each pin! Using XOR and AND you can quickly find which bit changed.

Where is Baroda?

Andy

chintan
Feb 26, 2008, 12:00 AM
Thanks for the reply Andykunz

I m from BARODA,GUJARAT,INDIA

sorry for that date i dont have that,
And can u tell me if i want to use 6 interrupts than is it possible to check that PIO_ISR register to check the individual occurence of the interrupt on the PIO.


there r 32bits in PIO_ISR and we have total 31 GPIO(PA0 to 30) so which bit is used for which pin or we have to ignore the MSB of PIO_ISR register.

AndyKunz
Feb 26, 2008, 07:29 AM
Since all the bits are coming to a single interrupt, I would expect that 1 interrupt would be all that is generated, and that bits for each possible pin would be set/cleared to denote if they are currently active changes. Figure 27-3 and paragraphs 27.4.10 seem to suggest that as well.

The last paragraph says When the software reads PIO_ISR, all the interrupts are automatically cleared. This signifies that all the interrupts that are pending when PIO_ISR is read must be handled.

This tells me (experimentation would verify) that multiple simultaneous pin changes will produce one interrupt, and that PIO_ISR would have bits set for each of them.

You will most likely need to check the other PIO registers (PIO_PSR in particular) to determine actual state. The way I interpret their documentation, you are going to get an interrupt when any of the pins in PIO_IER changes. You then need to check PIO_PSR for each pin to determine what to do.

PA0 is connected to PIOA registers in bit 0, PA1 is connected to PIOA registers in bit 1, PB0 is connected to PIOB registers in bit 0, etc. Bit 31 is not connected to external hardware on these particular devices. I imagine if they make a 144-pin device, they will be connected.

One of the other nice features of the Atmel PIO module is the ability to de-glitch (debounce) a pin in hardware. Section 27.4.9 explains how to do this. This would be very useful for an interrupt pin.

Do you have a hardware eval board you can test your ideas on? What development environment are you using?

Andy

chintan
Feb 26, 2008, 11:24 PM
Thanks a lot Andy,

i will check out that 27.4.9 clearly how it will be useful to me.

I m making hardware directly, I dont have any Eval board and i think it will be more cost effective and my Boss has ordered sample for this IC and he is also going to buy IDE with Jtag, i dont know which i will get at last and i m also waiting for that and now mostly completed my hardware design and will go for PCB. and when it completed i will start testing my ideas on my hardware as a Eval board.

Can u please suggest me is there any Free IDE or compiler available on the net for this device than please give link so i can download it.

Chintan

shanghai_fool
Feb 27, 2008, 12:10 AM
There are a couple of IDE/compilers available. One is the GNU toolchain. The instructions for use are available on Atmel website. IAR systems also have a kickstart edition available for AT91 series. Some of these tools also come with either development boards or the Atmel ICE interface. The schematic's for the Atmel development boards may also be available on Atmel website which may help designing your board.

The interrupt-on-change is not hard to use but my spaghetti code would probably do more harm than good. The Atmel website has many software apps and is the best place to start research.

Once the AIC is set up, the individual peripheral interrupts are fairly easy.

Donald

chintan
Mar 01, 2008, 05:56 AM
Thanks Donald
i will check out that

and i have one more Query related to SPI,
In this device support of 16bit is there but if i want to communicate with 24bit register device which replies with 24bit data on sdi pin so how to handle that received 24bit data

Chintan

AndyKunz
Mar 03, 2008, 09:38 AM
It depends.

If the device will accept 16-bit transfers (and ignore the extra 8 bits) then you can do two 16-bit transfers into a 32-bit variable, then mask off the bits you don't want.

Or, if the device is not happy with two 16-bit transfers, do the I/O as three 8-bits.

It depends on the SPI slave device. The best way to find out is to read the data sheet and then test it on your development board.

Andy