UART1
Answer
8/11/17 9:45 AM

I want to use UART1 port, which port is on the extended board. First I want to print information through PB9.

I had referenced the code in XDK Extension Bus User Guide. I hope use this code to print some characters in loop, but it's not working. I could not see any change on PB9, just can see information from console port. And I used one GPIO test code to test PB9, it can output high and low pulse, so this means the connection is ok.

Could you help to confirm why UART1 could not work?

 

void appInitSystem(xTimerHandle xTimer)
{
    BCDS_UNUSED(xTimer);
    init();
    init_uart1(xTimer);
  while(1)
    {
     printinformationuart1();
    }
}

 

Following are UART code:

#define UART_PRESENT
#define UART_COUNT 2
#define _CMU_HFPERCLKEN0_UART1_MASK
#include "Uart1.h"
#include "PTD_portDriver_ph.h"
#include "PTD_portDriver_ih.h"
#include "FreeRTOS.h"

/** Baudrate value for serial communication of BLE */
#define UARTBAUDRATE           (UINT32_C(115200))
/* Transmit Buffer size for USART Ringbuffer */
#define TX_BUFFER_SIZE              (UINT8_C(20))
/* Receive Buffer size for USART Ringbuffer */
#define RX_BUFFER_SIZE              (UINT8_C(20))
/** Serial transmit buffer for ringbuffer */
static uint8_t ser2TxBuf_ma[TX_BUFFER_SIZE];
/** Serial receive buffer for ringbuffer */
static uint8_t ser2RxBuf_ma[RX_BUFFER_SIZE];
static SER_device_t uart1_Handle;
static uint8_t writeBuf[TX_BUFFER_SIZE]="abcd\n";
/* Initializing serial init parameters */
static SER_init_t uartInit =
    {
        .hwType = SER_HWTYPE_UART,
        .hwDevicePort = SER_UART1,
        .protocol = SER_UART_PROTOCOL,
        .baudRate = 115200,
        .hasHwFlowControl = false,
        .txBuf_p = ser2TxBuf_ma,
        .txBufSize = 20,
        .rxBuf_p = ser2RxBuf_ma,
        .rxBufSize = 20,
        .parity = SER_PARITY_NONE,
        .dataBits = SER_DATABITS_8,
        .stopBits = SER_STOPBITS_ONE,
        .routeLocation = SER_ROUTE_LOCATION2,
        .txCallback = NULL,
        .rxCallback = NULL,
        .rtsPort = 0,
        .rtsPin = 0,
        .rtspolarity = SER_activeLow,
        .ctsPort = 0,
        .ctsPin = 0,
        .ctspolarity = SER_activeLow
      };
void init_uart1(xTimerHandle xTimer)
{
    //(void) (xTimer);
    BCDS_UNUSED(xTimer);
    /* Enable the UART clock */
     CMU_ClockEnable(cmuClock_UART1, true);
    /* Set the mode for a GPIO pin for UART control Signals */
    PTD_pinModeSet(PTD_GET_PORT_PIN_MODE_DOUT(EXTENSION_UART1_TX));
    PTD_pinModeSet(PTD_GET_PORT_PIN_MODE_DOUT(EXTENSION_UART1_RX));
    /* Initialize the Serial UART with the Configured parameters */
    SER_serialInit((SER_device_t*) &uart1_Handle,(SER_init_t*) &uartInit);
}
/*
This is just one test function, use uart1 to print one fixed message
*/
void printinformationuart1(void)
{
 printf("For test extended uart1\n");
 SER_serialWrite(&uart1_Handle, NULL, writeBuf, 5);
 printf("For test extended uart1, printed through UART1 port\n");
}
0 (0 Votes)
RE: UART1
Answer
8/11/17 1:48 PM as a reply to tom yang.

Hello tom!

Welcome to the community!

Let me see how I can help you. Firstly I looked into your code and found some interesting point, in

printinformationuart1() you instruct the uart1 to output a buffer called writeBuf, but I am not seeing where the contents passed to it, also do you see at least the start and stop bit from TXD pin?

Also, how you are checking the uart characters that uart1 outputs?

Best

Felipe

0 (0 Votes)
RE: UART1
Answer
8/11/17 4:55 PM as a reply to Felipe Neves.

Hello Tom,

I took a look at the mentioned UART pin. I used a multimeter to detect if the voltage level on the pin is changing, to verify if there is any output on the pin. As far as I can tell, the voltage level on the pin is changing, so on the first glance I assume that the pin is working.

Nevertheless, I am going to analyse this in more detail by setting up a complement device to read the sent UART messages from the XDK. I will get back to you early next week when I know more.  

Meanwhile, as Felipe already mentioned I would also like to know, what kind of device you used to conclude that the UART pin PB9 is not working. Did you use a remote device, which read the incoming UART messages?
In addition, did you test the unchanged UART example?
As far as I can see you made some changes in the example.

Regarding your question Felipe:

printinformationuart1() you instruct the uart1 to output a buffer called writeBuf, but I am not seeing where the contents passed to it, also do you see at least the start and stop bit from TXD pin?

He uses a static uint8_t array writeBuf as global variable, where he passes in the content “abcd\n”.

Kind regards,
Franjo

0 (0 Votes)
RE: UART1
Answer
8/12/17 9:55 AM as a reply to Franjo Stjepandic.

Hi Franjo,

I used two ways to confirm the output:

1) Used one multimeter to measure the voltage of pin, just as you had one, the voltage is always about 2.48V.

2) Connect PB9 to another UART port's input, did not show any information.

And as you said, you had seen the voltage change on the pin? Did you use my code?

I did not test the orginal example code to confirm this. According to the original code, I removed the RX section.

In fact I want to open UART1 to manage another board, at first I just test the output.

 

0 (0 Votes)
RE: UART1
Answer
8/14/17 2:00 PM as a reply to tom yang.

Hello Tom,

I did not use your code because you made more changes than only removing the RX section. An example for that is the init() function which is called in appInitSystem(), but not shown in your other posted code.

Today I set up an Arduino to transmit and receive data from the XDK. I wable able to send data from the Arduino to the XDK, and I was also able to receive data from it. Therefore I can confirm that the UART pin PB9 and the UART example are working.

To solve your issue, could you go more into detail what you mean with the following sentence:

Connect PB9 to another UART port's input, did not show any information.

Did you connect the UART Tx pin to another device or did you connect the UART Tx to the UART Rx pin of the XDK?

Additionally, I would ask you once again to check if the unchanged UART example is working on your XDK.

Kind regards,
Franjo

0 (0 Votes)