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 투표)