Reply
Posts: 8
Registered: ‎02-19-2016

What is the set up for the RS232 example of EZR32WG?

I'm trying to run the rs232 software example for the ezr32wg but I can't figure out where to see the serial cx. 

Posts: 204
Registered: ‎09-16-2015

Re: What is the set up for the RS232 example of EZR32WG?

suggest move to wireless forum for better visibility. ezr32wg is a wireless product.
<a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> rev
Posts: 313
Registered: ‎07-04-2014

Re: What is the set up for the RS232 example of EZR32WG?

Do you actually mean serial RX ? You said CX.

Post your code and it will be easier to help

 

Paul

Posts: 8
Registered: ‎02-19-2016

Re: What is the set up for the RS232 example of EZR32WG?

I'm just running the example code which comes in the Simplicity Studio IDE. As attached files you'll find what the README file says and the main.c code. I'm using ubuntu 14.04. 

 

Here the main.c:

 

int main(void)
{
int c;
int index;

/* Chip errata */
CHIP_Init();

/* Initialize LEUART/USART and map LF to CRLF */
RETARGET_SerialInit();
RETARGET_SerialCrLf(1);

#if defined(RETARGET_LEUART0)
printf("\nEZR32 LEUART example\n");
#elif defined(RETARGET_VCOM)
printf("\nEZR32 VCOM example\n");
#else
printf("\nEZR32 USART example\n");
#endif

for (index = 0; index < ECHOBUFSIZE; index++)
{
echoBuffer[index] = (char) 'a' + index;
}

/* Retrieve characters, print local echo and full line back */
index = 0;
while (1)
{
/* Retrieve new character */
c = getchar();
if (c > 0)
{
/* Output character - most terminals use CRLF */
if (c == '\r')
{
echoBuffer[index] = '\0';
/* Output entire line */
printf("\n%s\n", echoBuffer);
index = 0;
}
else
{
/* Filter non-printable characters */
if ((c < ' ') || (c > '~'))
continue;

/* Enter into buffer */
echoBuffer[index] = c;
index++;
if (index == ECHOBUFSIZE)
{
/* Flush buffer */
index = 0;
}
/* Local echo */
putchar(c);
}
}
}
}

 

Posts: 9
Registered: ‎02-15-2016

Re: What is the set up for the RS232 example of EZR32WG?

I'm having the same problem.  I was originally trying to get VCOM working on the EZR32WG, but that has been a completely failed effort.  I'm running on a MAC, I think I need a CDC driver to use VCOM over USB. I believe that driver does not exist for MAC, but I can't get an answer (I have a post on a different thread).

 

Anyway... back to the point.  I have tried USART1 and LEUART0 in an attempt to connect a serial output over the expansion header.  According the documentation:

   US1 TX is on PD0 EXP 4    (LOC 1)

   US2 TX is on PD1 EXP 6   (LOC 1)

   US2 CSE is on PD3  (no EXP) (LOC 1)

   LEU0 TX is on PD4 EXP 12   (LOC 0)

   LEU0 RX is on PD5 EXP 14  (LOC 0)

 

I've successfully produced output on bot EXP 12 (LEU0 TX) and EXP 4 (US1 TX), but the output is garbled in all cases.  The clock settings seem correct (i.e. 32K clock on LEU with DIV register = 616), but the output is still garbled.  Similar for the US1, and I've tried baud rates from 9600 to 115200.

 

In order to get that far, I had to perform major surgery on the redirect code for US1.  Here is the key code snippet.

================================================================================

void RETARGET_SerialInit(void)

{

  /* Enable peripheral clocks */

  CMU_ClockEnable(cmuClock_HFPER, true);

  /* Configure GPIO pins */

  CMU_ClockEnable(cmuClock_GPIO, true);

  /* To avoid false start, configure output as high */

  GPIO_PinModeSet(gpioPortD, 0, gpioModePushPull, 1);

  GPIO_PinModeSet(gpioPortD, 1, gpioModeInput, 0);

  GPIO_PinModeSet(gpioPortD, 3, gpioModePushPull, 1);

 

  USART_TypeDef           *usart = USART1;

  USART_InitAsync_TypeDef init   = USART_INITASYNC_DEFAULT;

 

  init.baudrate = 9600;

 

  CMU_ClockEnable(cmuClock_USART1, true);

 

  /* Configure USART for basic async operation */

  init.enable = usartDisable;

  USART_InitAsync(usart, &init);

 

  /* Enable pins at correct UART/USART location. */

  usart->ROUTE = USART_ROUTE_RXPEN | USART_ROUTE_TXPEN | USART_ROUTE_LOCATION_LOC1;

 

  /* Clear previous RX interrupts */

  USART_IntClear(usart, USART_IF_RXDATAV);

  NVIC_ClearPendingIRQ(USART1_RX_IRQn);

 

  /* Enable RX interrupts */

  USART_IntEnable(usart, USART_IF_RXDATAV);

  NVIC_EnableIRQ(USART1_RX_IRQn);

 

  /* Finally enable it */

  USART_Enable(usart, usartEnable);

 

#if !defined(__CROSSWORKS_ARM) && defined(__GNUC__)

  setvbuf(stdout, NULL, _IONBF, 0);   /*Set unbuffered mode for stdout (newlib)*/

#endif

 

  initialized = true;

}

============================================================================

Here is the key code snippet for LEU0 initialization:

============================================================================

LEUART_Init_TypeDef leuart0Init =

{

  .enable   = leuartEnableTx,       /* Activate data reception on LEUn_TX pin. */

  .refFreq  = 0,                    /* Inherit the clock frequency from the LEUART clock source */

  .baudrate = 9600,                 /* Baudrate = 9600 bps */

  .databits = leuartDatabits8,      /* Each LEUART frame containes 8 databits */

  .parity   = leuartNoParity,       /* No parity bits in use */

  .stopbits = leuartStopbits1,      /* Setting the number of stop bits in a frame to 2 bitperiods */

};

 

void initLEUART(void)

{

  /* Enabling clocks, all other remain disabled */

  CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFXO);

  CMU_ClockEnable(cmuClock_LEUART0, true);    /* Enable LEUART0 clock */

  // CMU_ClockDivSet(cmuClock_LEUART0, cmuClkDiv_1);

 

  LEUART_Reset(LEUART0);

  LEUART_Init(LEUART0, &leuart0Init);

 

  LEUART0->ROUTE = LEUART_ROUTE_TXPEN | LEUART_ROUTE_LOCATION_LOC0;

  GPIO_PinModeSet(gpioPortD, 4, gpioModePushPull, 1);

}

============================================================================

I'd appreciate any help too.  I can't seem to get a decent output on either expansion header pins of EZR32WG with either LEUART0 or USART1

 

Posts: 9
Registered: ‎02-15-2016

Re: What is the set up for the RS232 example of EZR32WG?

Sorry,  I was typing fast....  That should be:

   US1 TX is on PD0 EXP 4    (LOC 1)

   US1 RX is on PD1 EXP 6   (LOC 1)

   US1 CSE is on PD3  (no EXP) (LOC 1)

   LEU0 TX is on PD4 EXP 12   (LOC 0)

   LEU0 RX is on PD5 EXP 14  (LOC 0)

 

Posts: 9
Registered: ‎02-15-2016

Re: What is the set up for the RS232 example of EZR32WG?

 

Also note.  The USART config line yields the same result (garbage on output) for usartDisable and usartEnable (in case you spotted that in the source code above).

 

  init.enable = usartDisable;   // usartEnable produces the same result

 

Posts: 8,069
Registered: ‎08-13-2003

Re: What is the set up for the RS232 example of EZR32WG?

I do not know your board (you do not say starter kit/own board) and the schematic is not in the starter kit manual.

nyhow PD sounds like a port pin and you can NOT rin RS232 from a port pin, you need a RS232 transceiver such as the MAX3332

erik
Posts: 9
Registered: ‎02-15-2016

Re: What is the set up for the RS232 example of EZR32WG?

Thanks erikm.  It's a CMOS RS-232 and it requires a level converter.

 

Thanks again for the reply

Posts: 8,069
Registered: ‎08-13-2003

Re: What is the set up for the RS232 example of EZR32WG?

It's a CMOS RS-232 and it requires a level converter.

 

PLEASE STOP THIS!!!!

 

RS232 specifies signal levels so THERE IS NO SUCH THING as a "CMOS RS232"

erik
Posts: 9
Registered: ‎02-15-2016

Re: What is the set up for the RS232 example of EZR32WG?

Sorry for stating it incorrectly.  I didn't intend to make you angry.

Highlighted
Posts: 9
Registered: ‎02-15-2016

Re: What is the set up for the RS232 example of EZR32WG?

One other note (on the off-chance that a Silicon Labs employee reads these posts):

If the chip is not capable of driving the line at RS-232 levels (or TIA or EIA or whatever the 'proper' term is), then please don't call the software example XXX_rs232). 
In my case the software example is called SLWSTK6223A_rs232, causing my confusion.

 

I assumed the device was driving the pins at RS-232 levels, and that assumption was my error.

<a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> rev
Posts: 313
Registered: ‎07-04-2014

Re: What is the set up for the RS232 example of EZR32WG?

Hi Bitslinger, chips are not able to drive RS232 without a driver as is the case with nearly all micros from what i know. When doing an interface i normally use a convertor that takes the 3.3V voltage levels and converts to usb. But having said that i guess the project might be better named as SLWSTK6223A_UART

 

Paul

Posts: 8,069
Registered: ‎08-13-2003

Re: What is the set up for the RS232 example of EZR32WG?

If the chip is not capable of driving the line at RS-232 levels (or TIA or EIA or whatever the 'proper' term is), then please don't call the software example XXX_rs232).

 

doing so, in  itself is ridiculous, since RS232 is a voltage level standard, not a protocol standard.

erik
Posts: 8,069
Registered: ‎08-13-2003

Re: What is the set up for the RS232 example of EZR32WG?

I didn't intend to make you angry.

 

not angruy, just trying to REALLY make a point

erik
Posts: 10
Registered: ‎12-16-2015

Re: What is the set up for the RS232 example of EZR32WG?

I am having the same trouble. I defined RETARGET_LEUART0 in the project, and based on my reading of the code, I expect to be able to monitor output on the expansion header on pins 12/14, but I see nothing there when I put a logic analyzer on these pins.

 

I also tried to use the configurator tool to code generate the initialization code for LEUART0, and then write to the LEUART in another program derived from the examples and it is equally unsuccessful.

 

I was less than amused to see the code generated for initializing the LEUART was not the same as the code uses in the RS232 sample code,with several different steps in RS232 not in the code generated stuff.

 

There is a lot of stuff to initialize peripheral to the UART (clocks, routes, interrupts,etc). It would be nice if the code generator worked or that at least there were a working example so doing something as common as using a UART to exchange data wasn't a miserable hunting expedition that wastes days and days of people's time.