Serial -> lwIP Embedded WEB Server Demo

nobody wrote on Monday, March 19, 2007:

I’m using the lwIP Embedded WEB Server Demo using GCC on an AT91SAM7X256.
Now I like to communicate via the comport. So I need serial.c and serialISR.c
Anybody knows where I can find these files? Regards, Rick

hudson2009 wrote on Thursday, September 06, 2007:

yes i have the same problem. I can find serial.h in(full & minimal) folder but i just can’t find serial.c and SerialISR.c.
can any one contribute?

davedoors wrote on Thursday, September 06, 2007:

The SAM7S IAR demo has these files.  Start with these then convert them to use the GCC syntax for the interrupt handler.

hudson2009 wrote on Friday, September 07, 2007:

Thanks Dave,

I Manage to get the serial working with the ISR in Normal mode.

I am developing code for interfacing the serial with GPRS modem and i will need the serial in Modem or Hardware Mode.

I define my USART mode as follow the it doesn’t work:
// Define the USART mode                
//serCOM0->US_MR = AT91C_US_USMODE_NORMAL |  /* Normal Mode */
//serCOM0->US_MR = AT91C_US_USMODE_MODEM  |  /* Modem Mode  */
   serCOM0->US_MR = AT91C_US_USMODE_HWHSH|    /* Hardware Handshaking*/
                    AT91C_US_CLKS_CLOCK    |  /* Clock = MCK */
                    AT91C_US_CHRL_8_BITS   |  /* 8-bit Data  */
                    AT91C_US_PAR_NONE      |  /* No Parity   */
                    AT91C_US_NBSTOP_1_BIT;    /* 1 Stop Bit  */

Is this the right setting? or i will need more to get the MODEM or HWHSH mode working?


hudson2009 wrote on Friday, September 07, 2007:

//According to the AT91SAM7x256 datasheet (page316-317), 
hardware handshaking mode (RTS/CTS flow control).

I used the Hyperterminal to test it but failed.

//My code is as follows:

void Usart_init ( void )


  AT91C_BASE_PIOA, // PIO controller base address
  ((unsigned int) AT91C_PA5_RXD0    ) |
  ((unsigned int) AT91C_PA8_CTS0    ) |
  ((unsigned int) AT91C_PA7_RTS0    ) |
  ((unsigned int) AT91C_PA6_TXD0    ), // Peripheral A
  0); // Peripheral B ;

AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<<AT91C_ID_US0 ) ;

// Usart Configure
//I defined AT91C_US_ASYNC_MODE_HW in library

// Enable usart

COM0->US_RPR = (unsigned int)receive;  
COM0->US_RCR = 8;              

void main(void)

AT91F_US_ReceiveFrame (COM0, receive, 8, 0,0 );
while (AT91F_PDC_IsRxEmpty (AT91C_BASE_PDC_US0)==0){}

AT91F_US_SendFrame(COM0, receive,8,0,0);
while (AT91F_PDC_IsTxEmpty (AT91C_BASE_PDC_US0)==0){}

//This code is basically to receive a data buffer from Hyperterminal and echo back.

//The Hyperterminal is set in Hardware Flow Control mode.

//However, the UART could not receive anything from PC after I typed some characters in the Hyperterminal window. I probed the RTS0 pin (PA3) using oscilloscope and found that this pin was low (which was active). RTS low indicated to the remote device that it could start transmitting. So the UART was supposed to receive the buffer. Moreover, I used the PDC channel for reception as the datasheet stated.

//I have no idea why it does not work! All followed the datasheet. Anyone knows the RTS/CTS flow control can give me some hints?