EmbeddedRelated.com
Forums

spi pdc aic interupt

Started by gamerz267 January 23, 2008
i need some help with using aic with pdc. How do you initiate it. This
is how i set it up.

// Configure interupt when End of Transfer
AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);

// Configure the AIC for SPI interrupts
AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, SPI0_Handler);

// Enable the interrupt on the interrupt controller
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
Hi,

Did you set the peripheral clock (PMC_PCER) ?

Eric.
----- Original Message -----
From: gamerz267
To: A...
Sent: Thursday, January 24, 2008 3:28 AM
Subject: [AT91SAM] spi pdc aic interupt
i need some help with using aic with pdc. How do you initiate it. This
is how i set it up.

// Configure interupt when End of Transfer
AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);

// Configure the AIC for SPI interrupts
AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, SPI0_Handler);

// Enable the interrupt on the interrupt controller
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
Do you mean this

AT91F_PMC_EnablePeriphClock(
AT91C_BASE_PMC, // PIO controller base address
((unsigned int) 1 << AT91C_ID_SPI0));

// from lib_AT91SAM7X256.h
void AT91F_PMC_EnablePeriphClock (
AT91PS_PMC pPMC, // \arg pointer to PMC controller
unsigned int periphIds) // \arg IDs of peripherals
{
pPMC->PMC_PCER = periphIds;
}

--- In A..., "Eric Pasquier" wrote:
>
> Hi,
>
> Did you set the peripheral clock (PMC_PCER) ?
>
> Eric.
> ----- Original Message -----
> From: gamerz267
> To: A...
> Sent: Thursday, January 24, 2008 3:28 AM
> Subject: [AT91SAM] spi pdc aic interupt
> i need some help with using aic with pdc. How do you initiate it. This
> is how i set it up.
>
> // Configure interupt when End of Transfer
> AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);
>
> // Configure the AIC for SPI interrupts
> AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
> AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
SPI0_Handler);
>
> // Enable the interrupt on the interrupt controller
> AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
>
Yes.
You have to set the internal MCK clock for each peripheral, disconnected by default for lower consumption.

And, of course, you have to set others parmeters like number of bits, transfer rate, ... depending of your application.

Eric Pasquier
----- Original Message -----
From: gamerz267
To: A...
Sent: Thursday, January 24, 2008 11:24 PM
Subject: [AT91SAM] Re: spi pdc aic interupt
Do you mean this

AT91F_PMC_EnablePeriphClock(
AT91C_BASE_PMC, // PIO controller base address
((unsigned int) 1 << AT91C_ID_SPI0));

// from lib_AT91SAM7X256.h
void AT91F_PMC_EnablePeriphClock (
AT91PS_PMC pPMC, // \arg pointer to PMC controller
unsigned int periphIds) // \arg IDs of peripherals
{
pPMC->PMC_PCER = periphIds;
}

--- In A..., "Eric Pasquier" wrote:
>
> Hi,
>
> Did you set the peripheral clock (PMC_PCER) ?
>
> Eric.
>
>
> ----- Original Message -----
> From: gamerz267
> To: A...
> Sent: Thursday, January 24, 2008 3:28 AM
> Subject: [AT91SAM] spi pdc aic interupt
>
>
> i need some help with using aic with pdc. How do you initiate it. This
> is how i set it up.
>
> // Configure interupt when End of Transfer
> AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);
>
> // Configure the AIC for SPI interrupts
> AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
> AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
SPI0_Handler);
>
> // Enable the interrupt on the interrupt controller
> AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
>
ok the clock was already enabled. Do i have to enable it for the aic too?
If so how do i do that?
--- In A..., "Eric Pasquier" wrote:
>
> Yes.
> You have to set the internal MCK clock for each peripheral,
disconnected by default for lower consumption.
>
> And, of course, you have to set others parmeters like number of
bits, transfer rate, ... depending of your application.
>
> Eric Pasquier
> ----- Original Message -----
> From: gamerz267
> To: A...
> Sent: Thursday, January 24, 2008 11:24 PM
> Subject: [AT91SAM] Re: spi pdc aic interupt
> Do you mean this
>
> AT91F_PMC_EnablePeriphClock(
> AT91C_BASE_PMC, // PIO controller base address
> ((unsigned int) 1 << AT91C_ID_SPI0));
>
> // from lib_AT91SAM7X256.h
> void AT91F_PMC_EnablePeriphClock (
> AT91PS_PMC pPMC, // \arg pointer to PMC controller
> unsigned int periphIds) // \arg IDs of peripherals
> {
> pPMC->PMC_PCER = periphIds;
> }
>
> --- In A..., "Eric Pasquier" wrote:
> >
> > Hi,
> >
> > Did you set the peripheral clock (PMC_PCER) ?
> >
> > Eric.
> >
> >
> > ----- Original Message -----
> > From: gamerz267
> > To: A...
> > Sent: Thursday, January 24, 2008 3:28 AM
> > Subject: [AT91SAM] spi pdc aic interupt
> >
> >
> > i need some help with using aic with pdc. How do you initiate
it. This
> > is how i set it up.
> >
> > // Configure interupt when End of Transfer
> > AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);
> >
> > // Configure the AIC for SPI interrupts
> > AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
> > AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
> SPI0_Handler);
> >
> > // Enable the interrupt on the interrupt controller
> > AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
>
is there some special trick to get the interrupt working with spi. My
code doesnt cause a interupt. Am i doing something wrong??

AT91F_PMC_EnablePeriphClock(
AT91C_BASE_PMC, // PIO controller base address
((unsigned int) 1 << AT91C_ID_SPI0));

// Open PIO for SPI0
//AT91F_SPI0_CfgPIO();
AT91F_PIO_CfgPeriph(
AT91C_BASE_PIOA, // PIO controller base address
((unsigned int) AT91C_PA15_SPI0_NPCS3) |
((unsigned int) AT91C_PA16_SPI0_MISO) |
((unsigned int) AT91C_PA17_SPI0_MOSI) |
((unsigned int) AT91C_PA18_SPI0_SPCK), // Peripheral A
0); // Peripheral B

/*2. Configure interrupt for SPI0 in AIC*/
//AT91F_AIC_DisableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
// Configure the AIC for SPI interrupts
AT91F_AIC_ConfigureIt(
AT91C_BASE_AIC,
AT91C_ID_SPI0,
AT91C_AIC_PRIOR_HIGHEST,
AT91C_AIC_SRCTYPE_HIGH_LEVEL,
AT91F_SPI0_Interrupt_handler);
// Enable the interrupt on the interrupt controller
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);

/*3. Configuration SPI*/
// Reset SPI
//AT91F_SPI_Reset(AT91C_BASE_SPI0);

// Configure SPI in Master Mode with with cs
AT91F_SPI_CfgMode(AT91C_BASE_SPI0, SPI_MODE);

// Configure CSx
AT91F_SPI_CfgCs(AT91C_BASE_SPI0, 3, SPI_NPCS3_CONFIG); //CS3

// Configure interupt when End of Transfer
AT91F_SPI_EnableIt(AT91C_BASE_SPI0, AT91C_SPI_TDRE);

// SPI_Enable
AT91F_SPI_Enable(AT91C_BASE_SPI0);

--- In A..., "gamerz267" wrote:
>
> ok the clock was already enabled. Do i have to enable it for the aic
too?
> If so how do i do that?
> --- In A..., "Eric Pasquier" wrote:
> >
> > Yes.
> > You have to set the internal MCK clock for each peripheral,
> disconnected by default for lower consumption.
> >
> > And, of course, you have to set others parmeters like number of
> bits, transfer rate, ... depending of your application.
> >
> > Eric Pasquier
> >
> >
> > ----- Original Message -----
> > From: gamerz267
> > To: A...
> > Sent: Thursday, January 24, 2008 11:24 PM
> > Subject: [AT91SAM] Re: spi pdc aic interupt
> >
> >
> > Do you mean this
> >
> > AT91F_PMC_EnablePeriphClock(
> > AT91C_BASE_PMC, // PIO controller base address
> > ((unsigned int) 1 << AT91C_ID_SPI0));
> >
> > // from lib_AT91SAM7X256.h
> > void AT91F_PMC_EnablePeriphClock (
> > AT91PS_PMC pPMC, // \arg pointer to PMC controller
> > unsigned int periphIds) // \arg IDs of peripherals
> > {
> > pPMC->PMC_PCER = periphIds;
> > }
> >
> > --- In A..., "Eric Pasquier" wrote:
> > >
> > > Hi,
> > >
> > > Did you set the peripheral clock (PMC_PCER) ?
> > >
> > > Eric.
> > >
> > >
> > > ----- Original Message -----
> > > From: gamerz267
> > > To: A...
> > > Sent: Thursday, January 24, 2008 3:28 AM
> > > Subject: [AT91SAM] spi pdc aic interupt
> > >
> > >
> > > i need some help with using aic with pdc. How do you initiate
> it. This
> > > is how i set it up.
> > >
> > > // Configure interupt when End of Transfer
> > > AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);
> > >
> > > // Configure the AIC for SPI interrupts
> > > AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
> > > AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
> > SPI0_Handler);
> > >
> > > // Enable the interrupt on the interrupt controller
> > > AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
> > >
>
do i have it init it in start file to work??

something like this?? the startup file i have do have this...

/* Initialize AIC
****************/
AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;
AT91C_BASE_AIC->AIC_SVR[0] = (unsigned int) defaultFiqHandler;
for (i = 1; i < 31; i++) {

AT91C_BASE_AIC->AIC_SVR[i] = (unsigned int) defaultIrqHandler;
}
AT91C_BASE_AIC->AIC_SPU = (unsigned int) defaultSpuriousHandler;

// Unstack nested interrupts
for (i = 0; i < 8 ; i++) {

AT91C_BASE_AIC->AIC_EOICR = 0;
}

--- In A..., "gamerz267" wrote:
>
> i need some help with using aic with pdc. How do you initiate it. This
> is how i set it up.
>
> // Configure interupt when End of Transfer
> AT91F_SPI_EnableIt(pSPI, AT91C_SPI_ENDTX);
>
> // Configure the AIC for SPI interrupts
> AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI0,
> AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
SPI0_Handler);
>
> // Enable the interrupt on the interrupt controller
> AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI0);
>