How to reset flag of USB interruption?

OP #1173278
Hello

Please, help me.
I write my application based on BasicUSB example. Use SAM7-H256 olimex
board with AT91SAM7S256.

I decided to transfer USB data recive/send code from polling (main()
{...}) into USB interruption. But when I done it another code in main{}
stop working and my PC does not recognize my board.

Looks like that interuption function in some loop. Repeats again and
again. In PIC's, as I know, I should to clear interruption flag in
interruption code to retern to point where interruption happens. But how
do that in ARMs, espeialy in case of USB, I can't find.

Please, explain me how to build USB interruption corectily. To keep
main{} functionality.

Here is the code:


/* Interruspts programm when MC get some USB query */
void USB_Interrupt(void){

//This is my try to clear interruption
AT91F_UDP_InterruptClearRegister(AT91C_BASE_UDP, AT91C_UDP_SOFINT);
AT91F_AIC_ClearIt(AT91C_BASE_AIC, AT91C_ID_UDP);
}

/* To adjust USB interruption */
void USB_IR_init(void){

AT91F_AIC_ConfigureIt (AT91C_BASE_AIC, AT91C_ID_UDP,
USB_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, USB_Interrupt);
AT91F_UDP_EnableIt(AT91C_BASE_UDP, AT91C_UDP_SOFINT);
AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_UDP);
}


/* To connect to usb */
void PullUpResistor_Enable(void){
// Enable UDP PullUp (USB_DP_PUP) : enable & Clear of the corresponding
PIO
// Set in PIO mode and Configure in Output
AT91F_PIO_CfgOutput (AT91C_BASE_PIOA, AT91C_PIO_PA16);
// Clear for set the PullUp resistor
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, AT91C_PIO_PA16);
}



void AT91F_USB_Open(void)
{
// Set the PLL USB Divider
AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1 ;

// Specific Chip USB Initialisation
// Enables the 48MHz USB clock UDPCK and System Peripheral USB Clock
AT91C_BASE_PMC->PMC_SCER = AT91C_PMC_UDP;
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_UDP);

PullUpResistor_Enable();

// CDC Open by structure initialization
AT91F_CDC_Open(&pCDC, AT91C_BASE_UDP);
}



int main ( void ) {
char data[MSG_SIZE] = "";
unsigned int length;

AT91F_USB_Open(); // Init USB device
USB_IR_init();

while (1) {
if (pCDC.IsConfigured(&pCDC)) { // Check enumeration

//Get data from PC...
length = pCDC.Read(&pCDC, data, MSG_SIZE);
//Blah-blah-blah... Working code

pCDC.Write(&pCDC, data, length); //Send data to pc
}
}
}

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.