Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
926 Views

Using UART to interface a GSM module

Jump to solution

Hello!

I'm starting to work with D2000 uC and I want to connect UART_A to a GSM module and send AT commands. I've done this with other uCs (Cortex-M0, AVR). I read everything I've found about UARTS in d2000 uC and I have some questions. I'm used to write my own tx/rx interrupts and work with a FIFO for tx and another for RX. I'm looking for the correct way to code my app using QMSI.

For example, the "hello world" with a gsm module is to send AT and receive OK.

The transmit part is easy: qm_uart_write_buffer(QM_UART_0, (uint8_t *)"AT\n\r",sizeof("AT\n\r"));

After that command, the module takes some time to answer and send the OK string.

1- the OK string will be available on the RX buffer or should I request a non-blocking IRQ RX transfer? I used to send and wait for a time-out, then analyze the RX buffer for the OK string.

2- if yes, how can I read the RX buffer directly ?

3- if no, I need to setup a xfer, but in the xfer I need to specify the data lenght, but I don't always know the length of the data that I will receive.

thank you,

Jorge.

0 Kudos

Accepted Solutions
Highlighted
Employee
13 Views

Hi Jorge,

I believe the second approach would be the correct one to use, request a non-blocking IRQ RX transfer. I'm not sure if you have checked the GitHub examples about UART, if not here's the link https://github.com/quark-mcu/qmsi/blob/master/examples/uart/main.c https://github.com/quark-mcu/qmsi/blob/master/examples/uart/main.c. In that example they set an async_xfer_desc variable, setting the data, data length and callback.

Now to define the xfer, I can't think of an exact way to resolve this issue, but a possible workaround would be to set the length according to the maximum length of the buffer and set a signal that tells when the data has finished.

Regards,

-Pablo

View solution in original post

0 Kudos
2 Replies
Highlighted
Employee
14 Views

Hi Jorge,

I believe the second approach would be the correct one to use, request a non-blocking IRQ RX transfer. I'm not sure if you have checked the GitHub examples about UART, if not here's the link https://github.com/quark-mcu/qmsi/blob/master/examples/uart/main.c https://github.com/quark-mcu/qmsi/blob/master/examples/uart/main.c. In that example they set an async_xfer_desc variable, setting the data, data length and callback.

Now to define the xfer, I can't think of an exact way to resolve this issue, but a possible workaround would be to set the length according to the maximum length of the buffer and set a signal that tells when the data has finished.

Regards,

-Pablo

View solution in original post

0 Kudos
Highlighted
Novice
13 Views

Thank you Pablo! I will check the example.

0 Kudos