Wake from suspend on UART activity?

This forum is for users of Atmel's SAM Series and who are interested in using WinCE OS.

Moderator: nferre

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

Wake from suspend on UART activity?

Tue Jun 22, 2010 3:22 am

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
Adeneo
Contact:
Location: France - USA
Posts: 183
Joined: Fri May 14, 2004 9:58 am

Re: Wake from suspend on UART activity?

Tue Jun 22, 2010 1:53 pm

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.
ianscriven
Posts: 18
Joined: Wed Nov 25, 2009 4:15 am

Re: Wake from suspend on UART activity?

Wed Jun 23, 2010 6:51 am

Thanks for the reply. I've added some code to the serial driver (Serial_SAM926X) to (hopefully) do this:

Code: Select all

	///---------------------------------------------------------------------------------
	/// 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: Select all

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?
ianscriven
Posts: 18
Joined: Wed Nov 25, 2009 4:15 am

Re: Wake from suspend on UART activity?

Wed Jun 23, 2010 7:50 am

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: Select all

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?
Adeneo
Contact:
Location: France - USA
Posts: 183
Joined: Fri May 14, 2004 9:58 am

Re: Wake from suspend on UART activity?

Wed Jun 23, 2010 1:21 pm

Hi ianscriven,

To keep the clock of the Uart0, you must add (1 << AT91C_ID_US0) to your code

Code: Select all

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.
ianscriven
Posts: 18
Joined: Wed Nov 25, 2009 4:15 am

Re: Wake from suspend on UART activity?

Thu Jun 24, 2010 1:31 am

ianscriven wrote:Further update:
When the system suspends, I get the message

Code: Select all

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: Select all

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?
Adeneo
Contact:
Location: France - USA
Posts: 183
Joined: Fri May 14, 2004 9:58 am

Re: Wake from suspend on UART activity?

Thu Jun 24, 2010 11:16 am

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: Select all

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.

Return to “WinCE”

Who is online

Users browsing this forum: No registered users and 1 guest