Sending data via UART
응답
15. 6. 25 오전 11:44
Hello,

I have tried to send data via the UART interface. The routines SET_SerialInit and SER_serialWrite give back  SER_SUCCESS but there is not output to the pins. Only the buffer seems to be filled, if the buffer is full, an error is returned. I have tried UART, USART, LEUART, both ports (U1 and U2) and different baud rates.
How can I send the data to the pins?

Thanks,

Jürgen Schuster
 
0 (0 투표)
Sending data via UART
응답
15. 6. 26 오전 9:39 as a reply to Jürgen Schuster.
Hello,

In the meantime I've also tried to send via GPIO and SPI. GPIO works, but I don't want to morse my data. SPI doesn't work, I've tried SPI1 and SPI2 with different baud rates, there is no clock and no data on any pins, but SPI_init and SPI_write return SPI_SUCCESS. Has anyone ever tried this successfully?

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 6. 26 오전 11:14 as a reply to Jürgen Schuster.
Hello Jürgen,

the SER_serialWrite function does not deliver data to the remote device directly. To use this function merely copies the supplied data to an internal ring buffer as you have mentioned. 

A very good example for SPI is at:

platform\device\sdcard\SDC_sdCardDriver\SDC_sdCardDriver_cc.c

in the following functions:

·         sdCardSpiInitialize
·         sdCardSendCmd
·         sdCardBlockReceive

Please let me know, if this helps you!

Regards,
Manuel
0 (0 투표)
Sending data via UART
응답
15. 6. 29 오전 7:02 as a reply to Manuel Cerny.
Hallo Manuel,

Yes, so says the documentation too. But now, how to send the data in the ring buffer to the pins? SPI_write does not much more than calling SER_serialWrite. When I enable the UART1  clock, the ring buffer doesn't overflow. But where ist the output?
As I see, the sdCard driver uses SPI1. So where is the port to the pins B1-4 = U1 and B5-8 = U2?

Thanks,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 6. 29 오전 11:28 as a reply to Jürgen Schuster.
Dear Jürgen,

I assume that you try to connect to the extension bus of the XDK, not to the SD card.
I general, most of the pins work as GPIOs and can be configured to specific fuctionalities; to avoid interfering with internal functions we give some recommendations which pins should be used if you want to connect a UART or USART device.
As an example, if you are connecting an SPI device via the extension board (USART2), it should work with
PB3: SPI_MOSI
PB4: SPI_MISO
PB5: SPI_CLK
PD8: SPI_CS
Pleas note that all pins on the extension bus work on a voltage level of 2.5V

Best regards,
Mathias
0 (0 투표)
Sending data via UART
응답
15. 6. 29 오후 12:29 as a reply to Mathias Bruendel.
Dear Mathias,

I have read  the documentation, so  I know the pinset you mentioned (see: XDK_Getting_Started_v1). But there comes nothing out of these pins when using SPI or U(S)ART. I can use the pins as GPIOs, so it seems that these pins are normally assigned to GPIO. How to assign them to U(S)ART?

Thanks,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 6. 30 오후 2:20 as a reply to Jürgen Schuster.
Dear Jürgen,

after some investigation we found an eror in our documentation. The pins for the SPI interface pins on the extension bus connector (and the "Gateway" board) are swapped compared to the table given in the getting started guide.
PB4 (US2_MISO) is located on pin B5, PB3 (US2_MOSI) on pin B6.
Note that the print on the Gateway V1.0 is false.
Maybe this helps to clarify the observed problem. I am sorry for the inconvenience caused by this flaw. The documentation will be updated within the next days.

Best regards,
Mathias

 
0 (0 투표)
Sending data via UART
응답
15. 7. 1 오전 5:50 as a reply to Mathias Bruendel.
Dear Mathias,

Yes, the swap of the pins I already know, since I tested the GPIO pins. But I checked every pin when trying UART and SPI, and there was nothing (except the 3.3V, 2.5V and the I2C-Pins PB11/12, which are pulled up). I still think it is a software problem in the configuration of the pins to GPIO. Or do you have a working example with UART or SPI to the extension pins?

Bye,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 7. 7 오후 1:57 as a reply to Jürgen Schuster.
Hello everybody,

After that I already gave up, a colleague of mine found the solution. You have to configurate the TX-pin as GPIO output and use the correct location (not in XDK documentation). Now I can send data via UART (U1_TX = PB9 at location 2).

Bye,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 7. 10 오전 6:40 as a reply to Jürgen Schuster.
Dear Jürgen,

is there any code using UART, that you could share?
Currently I amworking with the XDK and I have problems with implementing the functions.

I am looking forward to your response!

Best regards, Chris
0 (0 투표)
Sending data via UART
응답
15. 7. 10 오전 7:09 as a reply to Wang Ben.
Dear Chris,

This is the initialization:
    // configures Pin B9 = U1_TX as output
    GPIO_handleInfo_t info;
    info.port = gpioPortB;
    info.bitIndex = 9;
    info.magicWord = GPIO_HANDLE_MAGIC_WORD;
    GPIO_init(&info, GPIO_DIRECTION_OUTPUT, GPIO_STATE_OFF);
    // initializes UART1
    CMU_ClockEnable(cmuClock_UART1, true);
    SER_init_t init;
    init.hwType = SER_HWTYPE_UART;
    init.hwDevicePort = SER_UART1;
    init.protocol = SER_UART_PROTOCOL;
    init.baudRate = 115200;
    //init.hasHwFlowControl = 0;
    init.txBuf_p = (uint8_t*)&serialTxBuffer;
    init.txBufSize = sizeof(serialTxBuffer);
    init.rxBuf_p = (uint8_t*)&serialRxBuffer;
    init.rxBufSize = sizeof(serialRxBuffer);
    init.parity = SER_PARITY_NONE;
    init.dataBits = SER_DATABITS_8;
    init.stopBits = SER_STOPBITS_ONE;
    init.routeLocation = SER_ROUTE_LOCATION2;
    init.txCallback = NULL;
    init.rxCallback = NULL;
    SER_device_t serialDevice;
    SER_serialInit(&serialDevice, &init);

And you send data with:
    SER_serialWrite(&serialDevice, NULL, &data, (uint32_t)strlen(data));

I hope I could help.

Bye,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 7. 10 오전 7:46 as a reply to Jürgen Schuster.
Dear Jürgen,

thank you for your fast response!

I have the same problem with your code that I have with my own...
SER_serialInit always gives back SER_UNREACHABLE and I can't figure out why.
Have you ever had that error?

Best regards, Chris
 
0 (0 투표)
Sending data via UART
응답
15. 7. 10 오전 9:10 as a reply to Wang Ben.
Dear Chris,

Oh, the documentation says that this return is fatal and should never happen! I never had this error, so you might report BCDS this problem as mentioned?

Best regards,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 7. 13 오전 1:03 as a reply to Jürgen Schuster.
Dear Jürgen,

I just copied my code to a new project and everything worked fine...I have no idea why it is working now, but at least I can go on with my work.

Thank you for your help!

Best regards,
Chris
0 (0 투표)
Sending data via UART
응답
15. 7. 14 오전 8:10 as a reply to Wang Ben.
Dear Jürgen,

actually I came across the problem of getting "2 (SER_RESOURCE)" as return from any SER_serialWrite or SER_serialRead function and I can not figure out why. My buffers should be big enough and I have tested that the Arduino I am using for sending/receiving is working properly...

Do you have a working example project for me?

Thank you for your help!

Best regards,
Chris
0 (0 투표)
Sending data via UART
응답
15. 7. 14 오전 9:02 as a reply to Wang Ben.
Dear Chris,

Have you enabled the clock of the port you use? Look above in my working code:
CMU_ClockEnable(cmuClock_UART1, true);
Without this line, SER_serialWrite only fills the buffer, but the data will never be sent to the pins. When the buffer is full, the function returns 2.
I hope I could help.

Bye,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 7. 15 오전 2:29 as a reply to Jürgen Schuster.
Dear Jürgen,

actually I am using exactly your code. I just copied it because I couldn't get mine running. I asked you again since I can't get your code working as well....

Best regards,
Chris
 
0 (0 투표)
Sending data via UART
응답
15. 7. 15 오전 5:54 as a reply to Wang Ben.
Dear Chris,

On our XDKs my code works without problems. And the complete code is not much more than the snippet I posted. Just some code to read out the sensors and put the values in the sending string. I have no idea why this doesn't work for your project, I'm sorry. I think I can send you the complete .c file if this helps, so let me know.

Bye,

Jürgen
 
0 (0 투표)
Sending data via UART
응답
15. 7. 16 오전 7:09 as a reply to Jürgen Schuster.
Dear Jürgen,

thank you for the offer of sending me your code! I would really appreciate it!
My mail address:

Best regards,
Chris
 
0 (0 투표)
RE: Sending data via UART
응답
16. 8. 4 오전 6:40 as a reply to Wang Ben.

Hey,

This post was a while ago but I am experiencing a similar issue.

 How are you definging init.txBuf_p and what is serialTxBuffer and how is it defined? Im struggling with this part and not really sure how to get past it.

 

Thanks! 

0 (0 투표)
RE: Sending data via UART
응답
16. 8. 4 오후 4:48 as a reply to Garret Holt.

Hello Garret,

you can find the definition of init.txBuf_p in the UART interface SER_serialDriver_ih.h. It defines a pointer to a buffer that holds the bytes that are transmitted. serialTxBuffer is defined by Jürgens application and is used as the required buffer.

Kind regards,
Franjo

0 (0 투표)
RE: Sending data via UART
응답
16. 8. 5 오전 7:34 as a reply to Franjo Stjepandic.

Hi Franjo,

 

Thanks for the reply. So can the buffer just any spot in memory allocated for the data such as

uint32_t txbuffer[5], rxbuffer[5];

 

Garret

0 (0 투표)
RE: Sending data via UART
응답
16. 8. 7 오후 12:39 as a reply to Garret Holt.

Hello Garret,

yes you are correct. The buffer should work fine with the posted code.

Please don't hesitate to ask, if you have further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 16 오후 2:32 as a reply to Franjo Stjepandic.

Hello guys,

I've been trying to use the UART ports on the XDK gateway but I'm still struggling to send anything. My code runs but nothing is received on the other end.

I noticed one thing though when I try the UART example here: http://xdk.bosch-connectivity.com/xdk_docs/html/_x_d_k__e_x_t_e_n_s_i_o_n__b_u_s__g_u_i_d_e.html

the value SER_UART1 is seen as undeclared, I have to use the enum value instead to bypass it, but there maybe a link with my UART not working. I have included "SER_serialDriver_ih.h" and when I mouse over the SER_UART1 line in this file, the enum value is correctly displayed.

Any idea?

Thanks,

Aurelien

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 16 오후 7:02 as a reply to Aurelien Lequertier.

Hello Aurelien,

I checked the example of the XDK extension guide and observed that there some include parts and variable declarations missing.

I recommend to include the following code snippet above the extension guide code and try it once again.

#include "PTD_portDriver_ih.h"
#include "PTD_portDriver_ph.h"
#include "SER_serialDriver_ih.h"
#include "em_cmu.h"

/** creating the serial Instance for future reference */
static SER_device_t uartHandle;

/* 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];

Please tell me if this helps you to get your implementation running and do not hesitate to ask if there is anything unclear.

Kind regards,
Franjo

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 17 오전 11:05 as a reply to Franjo Stjepandic.

Hi Franjo,

Right I had already added the missing statements. I found my problem yesterday, apparently the 3.3V and 2.5V pins don't work or don't supply enough current. I was able to make it work by connecting my UART module to an external power supply.

Should I initialize the power pins on the gateway, or is there a max current that can be supplied by it?

Thanks,

Aurelien

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 17 오후 12:56 as a reply to Aurelien Lequertier.

I found the way while looking at the definition of SDCardDriver_Init(). The following statement enables the 2 power pins on the gateway:

PTD_pinModeSet(PTD_GET_PORT_PIN_MODE_DOUT(WIFI_SD_VDD_PORT));

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 17 오후 9:09 as a reply to Aurelien Lequertier.

Hello Aurelien,

as I understand you try to supply an additional external UART module to receive the data from the XDK.
Am I right so far?

If this is the case it depends on the power consumption of your module. The 3.3 V and 2.5 V pins have a maximum output of 100 mA.
If your UART module requires a greater amount of supply current, your choice using an external supply source should be the way to go.
Otherwise you can use them and activate via PTD_pinModeSet() as you already mentioned.

Please tell me if this helps you and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 20 오후 3:28 as a reply to Franjo Stjepandic.

Hi Franjo,

You're correct. My module draws up to 50 mA every few minutes so it is fine.

Thanks for your help!

Aurelien

 

0 (0 투표)
RE: Sending data via UART
응답
17. 2. 20 오후 6:09 as a reply to Aurelien Lequertier.

Hello Aurelien,

I am glad to hear that this fits for your purpose.

Please do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 투표)