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  [ 7 posts ] 
Author Message
 Post subject: Wake from suspend on UART activity?
PostPosted: Tue Jun 22, 2010 3:22 am 
Offline

Joined: Wed Nov 25, 2009 4:15 am
Posts: 18
Hi,

Is there any reason why I can't wake WinCE (6.0) from suspend when UART activity occurs? Can I assign a sys interrupt to the RXD pin of the uart? This is how the KeyPad driver achieves this, isn't it?

Thanks,
Ian


Top
 Profile  
 
 Post subject: Re: Wake from suspend on UART activity?
PostPosted: Tue Jun 22, 2010 1:53 pm 
Offline

Joined: Fri May 14, 2004 9:58 am
Posts: 183
Location: France - USA
Hi ianscriven,

You can't wake-up your platform directly with the RxD pin.
We have never tried to wake-up a board with a serial COM port but that is theoretically possible.
You can try to call KernelIoControl with IOCTL_HAL_ENABLE_WAKE and the SysIntr that correspond to the interrupt of your serial port.

HTH

If this answer solves your problem, please edit the subject of this post by adding [Solved] at the beginning of the subject.

_________________
Adeneo Embedded
http://www.adeneo-embedded.com


Top
 Profile  
 
 Post subject: Re: Wake from suspend on UART activity?
PostPosted: Wed Jun 23, 2010 6:51 am 
Offline

Joined: Wed Nov 25, 2009 4:15 am
Posts: 18
Thanks for the reply. I've added some code to the serial driver (Serial_SAM926X) to (hopefully) do this:
Code:
   ///---------------------------------------------------------------------------------
   /// Interrupt Init

   // Request sysintr for the device
   pSerialInitStructure->dwSysIntr = SYSINTR_UNDEFINED;
   if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, (PVOID)&pSerialInitStructure->dwDeviceID, sizeof(pSerialInitStructure->dwDeviceID), (PVOID)&pSerialInitStructure->dwSysIntr, sizeof(pSerialInitStructure->dwSysIntr), NULL))
   {
      RETAILMSG(1, (TEXT("ERROR: Failed to request the serial sysintr for USART XX.\r\n")));
      pSerialInitStructure->dwSysIntr = SYSINTR_UNDEFINED;
      goto error;
   }
   
   // new code to enable wake on serial?
   if(!KernelIoControl(IOCTL_HAL_ENABLE_WAKE, (PVOID)&pSerialInitStructure->dwSysIntr   , sizeof(pSerialInitStructure->dwSysIntr)  , &dwResult   , sizeof(dwResult   ), 0))
   {
      RETAILMSG(1, (TEXT("IOCTL_HAL_ENABLE_WAKE failed\n\r")));
   }


This doesn't work - I'm guessing the UART is turned off when the device suspends, preventing the interrupt from being generated? If so, how can I make sure it is left enabled? I'm using USART0, so the tx/rx pins are on PIOA, which, according to this line from BSPPowerOff, should still be active?
Code:
pPMC->PMC_PCDR = ~((1 << AT91C_ID_PIOCDE) | (1 << AT91C_ID_PIOA) | (1 << AT91C_ID_AC97C) | (1 << AT91C_ID_2DGE) | (1 << AT91C_ID_EMAC));      //0xFF5BFFEB


Anyone have any ideas?


Top
 Profile  
 
 Post subject: Re: Wake from suspend on UART activity?
PostPosted: Wed Jun 23, 2010 7:50 am 
Offline

Joined: Wed Nov 25, 2009 4:15 am
Posts: 18
Further update:

I've edited the BSPPowerOff function to keep the peripheral clock for USART0 enabled. When the system suspends, I get the message
Code:
OALPowerWakeSource enable 14

on debug rs232 - the interrupt for USART0 is 20 - it seems the USART interrupt isn't being configured as a wakeup source... what am I doing wrong?


Top
 Profile  
 
 Post subject: Re: Wake from suspend on UART activity?
PostPosted: Wed Jun 23, 2010 1:21 pm 
Offline

Joined: Fri May 14, 2004 9:58 am
Posts: 183
Location: France - USA
Hi ianscriven,

To keep the clock of the Uart0, you must add (1 << AT91C_ID_US0) to your code
Code:
pPMC->PMC_PCDR = ~(
   (1 << AT91C_ID_PIOCDE) |
   (1 << AT91C_ID_PIOA) |
   (1 << AT91C_ID_AC97C) |
   (1 << AT91C_ID_2DGE) |
   (1 << AT91C_ID_EMAC) |
   (1 << AT91C_ID_US0)
);

HTH

If this answer solves your problem, please edit the subject of this post by adding [Solved] at the beginning of the subject.

_________________
Adeneo Embedded
http://www.adeneo-embedded.com


Top
 Profile  
 
 Post subject: Re: Wake from suspend on UART activity?
PostPosted: Thu Jun 24, 2010 1:31 am 
Offline

Joined: Wed Nov 25, 2009 4:15 am
Posts: 18
ianscriven wrote:
Further update:
When the system suspends, I get the message
Code:
OALPowerWakeSource enable 14

on debug rs232 - the interrupt for USART0 is 20...


Never mind this... 20d is 14h, what was I thinking...

The uart should be enabled, like you say, I have
Code:
pPMC->PMC_PCDR = ~((1 << AT91C_ID_PIOCDE) | (1 << AT91C_ID_PIOA) | (1 << AT91C_ID_AC97C) | (1 << AT91C_ID_2DGE) | (1 << AT91C_ID_EMAC) | (1 << AT91C_ID_US0));

in the BPSPowerOff function. No joy as yet though, I'll keep working on it.

Would it be easier to get WinCE to wake on USB device activity?


Top
 Profile  
 
 Post subject: Re: Wake from suspend on UART activity?
PostPosted: Thu Jun 24, 2010 11:16 am 
Offline

Joined: Fri May 14, 2004 9:58 am
Posts: 183
Location: France - USA
Hi ianscriven,

Have you modified the SOCSaveAndDisableAllIntrBeforeSuspend function located in the WinCE600\PLATFORM\COMMON\SRC\SOC\ATMEL\AT91SAM926x\KERNEL\INTR\intr.c file?
You must keep alive the interrupt for your wakeup source like below (not tested).
Code:
void SOCSaveAndDisableAllIntrBeforeSuspend()
{
   RETAILMSG(1, ( L"+SOCSaveAndDisableAllIntrBeforeSuspend()\r\n" ));    
    AICResumeMask = g_pAIC->AIC_IMR;
   g_pAIC->AIC_IDCR = 0xFFFFFFFF; //mask all the interrupts
   SOCPioSaveAndDisableAllIntrBeforeSuspend();
   SOCPioControllerIntrEnable(); //Leave the interrupt for the pio controllers !
   g_pAIC->AIC_IECR = 1 << AT91C_ID_US0; //unmask UART0 interrupt
}

HTH

If this answer solves your problem, please edit the subject of this post by adding [Solved] at the beginning of the subject.

_________________
Adeneo Embedded
http://www.adeneo-embedded.com


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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: