Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: DBGU Interrupt question
PostPosted: Thu Feb 18, 2010 10:38 pm 
Offline

Joined: Thu Jan 24, 2008 12:28 am
Posts: 3
Hello,

I have been working for several days trying to get the DBGU interrupt working. I have written a system interrupt handler which seems to be working fine for the PIT interrupt and does vector as expected to the DBGU ISR. The program hangs when the DBGU interrupt is enabled and does not seem to be returning from the interrupt. Your advice is much appreciated.

The entry point is at bottom, Configure_IO_Pins ();

Here's the code.

//------------------------------------------------------------------------------
// Handler for PIT interrupt. Increments the timestamp counter.
//------------------------------------------------------------------------------
void ISR_Pit(void)
{
// Read the PIVR to acknowledge interrupt and get number of ticks
timestamp += (PIT_GetPIVR() >> 20);
}

//------------------------------------------------------------------------------
// Handler for DBGU interrupt.
//------------------------------------------------------------------------------
void ISR_Dbgu (void)
{
volatile unsigned char c;

// Read the character from the receiver holding register
c = AT91C_BASE_DBGU->DBGU_RHR;

LED_Set (0);
LED_Set (1);
LED_Set (2);

// Reset the status bits (parity error, framing error, overrun)
AT91C_BASE_DBGU->DBGU_CR = AT91C_US_RSTSTA;
}

//------------------------------------------------------------------------------
// Handler for System peripheral interrupt
//------------------------------------------------------------------------------
void ISR_System (void)
{
unsigned int status, enabled; //, vector;

// The system peripheral interrupt will fire from the following interrupt sources:
// pit_irq, rtt_irq, wdt_irq, dbgu_irq, pmc_irq, rstc_irq
// This ISR will check each interrupt's status register to determine which
// source triggered the interrupt, and handle it accordingly.
// This function will check the source of the interrupt, as well as the interrupt enable
// for each trigger to prevent handling of functions which did not trigger an interrupt.

// Read the PIVR register to begin interrupt handling
// This must be done for the AIC to acknowledge that the interrupt is being handled
//vector = AT91C_BASE_PITC->PITC_PIVR;
//++vector;

// ** CHECK PIT INTERRUPT **
// Read the PIT status register for interrupt triggered
status = AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS;
// Read the PIT mode register for interrupt enabled
enabled = AT91C_BASE_PITC->PITC_PIMR & AT91C_PITC_PITIEN;
if ((status != 0) && (enabled != 0))
{
ISR_Pit ();
}

// ** CHECK RTT INCREMENT INTERRUPT **
// Read the RTT status register for interrupt triggered
status = AT91C_BASE_RTTC->RTTC_RTSR & (AT91C_RTTC_RTTINC | AT91C_RTTC_ALMS);
// Read the RTT mode register for interrupt enabled
enabled = AT91C_BASE_RTTC->RTTC_RTMR & (AT91C_RTTC_RTTINCIEN | AT91C_RTTC_ALMIEN);
if ((status & enabled) != 0)
{
// Handle RTT interrupt here
}

// ** CHECK WDT INTERRUPT **
// Read the WDT status register for interrupt triggered
status = AT91C_BASE_WDTC->WDTC_WDSR & AT91C_WDTC_WDUNF;
// Read the WDT mode register for interrupt enabled
enabled = AT91C_BASE_WDTC->WDTC_WDMR & AT91C_WDTC_WDFIEN;
if ((status != 0) && (enabled != 0))
{
// Handle WDT interrupt here
}

// ** CHECK DBGU INTERRUPT **
// Read the DBGU status register for interrupt triggered
status = AT91C_BASE_DBGU->DBGU_CSR;
// Read the DBGU mode register for any interrupt enabled
enabled = AT91C_BASE_DBGU->DBGU_IMR;
// For DBGU, check for an enabled interrupt with the corresponding trigger
if ((status & enabled) != 0)
{
// Handle DBGU interrupt here
ISR_Dbgu ();
}

// ** CHECK PMC INTERRUPT **
// Read the PMC status register for interrupt triggered
status = AT91C_BASE_PMC->PMC_SR;
// Read the PMC mode register for any interrupt enabled
enabled = AT91C_BASE_PMC->PMC_IMR;
if ((status & enabled) != 0)
{
// Handle PMC interrupt here
}

// ** CHECK RSTC INTERRUPT **
// Read the RSTC status register for interrupt triggered
status = AT91C_BASE_RSTC->RSTC_RSR & (AT91C_RSTC_URSTS | AT91C_RSTC_BODSTS);
// Read the RSTC mode register for interrupt enabled
enabled = AT91C_BASE_RSTC->RSTC_RMR & (AT91C_RSTC_URSTIEN | AT91C_RSTC_BODIEN);
if ((status & enabled) != 0)
{
// Handle RSTC interrupt here
}

// Clear interrupt
//AT91C_BASE_AIC->AIC_EOICR = 0;
//AT91C_BASE_AIC->AIC_ICCR = 1 << AT91C_ID_SYS;
}

//------------------------------------------------------------------------------
// Configures the system interrupt which calls ISR_System when on of the following
// interrupts triggers: PIT, RTT, WDT, DBGU, PMC, RSTC
// Note: This function should be called before configuring any of the above interrupts.
//------------------------------------------------------------------------------
void ConfigureSystemInt (void)
{
// Disable the interrupt
AIC_DisableIT(AT91C_ID_SYS);

// Configure the system interrupt for lowest priority, level sensitive, and ISR name
AIC_ConfigureIT(AT91C_ID_SYS, (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL), ISR_System);
//AIC_EnableIT(AT91C_ID_SYS);
}

//------------------------------------------------------------------------------
// Enables the system interrupt
//------------------------------------------------------------------------------
void EnableSystemInt (void)
{
AIC_EnableIT(AT91C_ID_SYS);
}

//------------------------------------------------------------------------------
/// Configure the periodic interval timer to generate an interrupt every
/// millisecond.
//------------------------------------------------------------------------------
void ConfigurePit(void)
{
// Initialize the PIT to the desired frequency
PIT_Init(PIT_PERIOD, BOARD_MCK / 1000000);

// Configure system interrupt
// AIC_DisableIT(AT91C_ID_SYS);
// AIC_ConfigureIT(AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, ISR_System);
// AIC_EnableIT(AT91C_ID_SYS);

// Enable PIT interrupt
PIT_EnableIT();

// Enable the pit
PIT_Enable();
}

//------------------------------------------------------------------------------
/// Configures the IO Pins for the CPU Board
//------------------------------------------------------------------------------

void Configure_IO_Pins (void)
{
static const Pin pin_sps = PIN_SPS;
static const Pin display_bits = DISPLAY_BITS;
const Pin pinsDbgu[] = PINS_DBGU;

// Configure DBGU pins
PIO_Configure(pinsDbgu, PIO_LISTSIZE(pinsDbgu));

// Configure DBGU mode
DBGU_Configure(DBGU_STANDARD, 115200, BOARD_MCK);

// Enable NRST pin, disable interrupts, set reset time to 1 second
Configure_Reset (1,0,0,8);

// Configure PIT
ConfigurePit();

// Configure Timer/Counter
//ConfigureTc();

// Configure Button Inputs
//ConfigureButtons();

// Configure LED outputs
ConfigureLeds();

// Configure TWI
ConfigureTWI ();

// Configure the SPS (Serial port select) output pin
PIO_Configure (&pin_sps, 1);

// Configure the Display Output pins
PIO_Configure (&display_bits, 1);

// Configure the system interrupt
// This should be configured first, then config any
// devices which use the system interrupt.
ConfigureSystemInt ();

// Enable the system interrupt
EnableSystemInt ();
}


Top
 Profile  
 
 Post subject: Re: DBGU Interrupt question
PostPosted: Fri Feb 19, 2010 8:37 pm 
Offline

Joined: Thu Jan 24, 2008 12:28 am
Posts: 3
Well, I'm going to answer my own question here in case anyone else made the same stupid mistake as me.

turns out that all of this works fine. I just enabled the wrong interrupt. I used the ENDRX interrupt and should have used the RXRDY interrupt instead. Switched to this one and it works fine.

PEBKAC error - Problem Exists Between Keyboard And Chair...

Rick


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: