This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_uart_put

Hi everyone

I am using app_uart_put() method for sending data via UART. The problem is that when I send each byte I get each byte back to its event handler in APP_UART_DATA_READY state. I would like to get only received data on APP_UART_DATA_READY state. I will appreciate for help in advance.

  • Hi Karl,

    thanks for your help. I am pretty sure that RealTerm works fine. For example, if I send "AT\r\n" I get back "OK" on REalTerm. If I do the same via the ble module I get back "AT\r\n OK ". At the moment I do not get access to a logic analyzer. 

    I do not use a basic peripheral example I use ble peripheral example.

           ...
           sending_data_uart("AT\r\n", 4);
           err_code = app_timer_start(sending_data_to_server_id, INTERVAL_2500MS ,NULL);
           APP_ERROR_CHECK(err_code);
           ...
           
    
    void sending_data_uart(uint8_t * data, uint16_t len)
    {
        uint32_t err_code;
    
        for (uint16_t i = 0; i < len; i++)
        {
            
            do
            { 
                
                err_code = app_uart_put(data[i]);
                if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
                {
                    NRF_LOG_ERROR("Failed Error 0x%x. ", err_code);
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);        
        }    
    }
    
    
    
    

    The inner resistor is used for Rx pin. It is achieved by applying the following code after uart_init()- 

     nrf_gpio_cfg(RX_PIN_NUMBER, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);

    It is not a secret that our cellular module is SIMCOM 7020 which is connected with ble module via UART. Do you think that I have a problem because I use RTT for logging?

    NRF_LOG_BACKEND_RTT_ENABLED 1

    I really do not know what can be wrong I spend a few days and I did not figure out what is going on.

  • Hello Samo,

    control said:
    thanks for your help.

    No problem at all, I am happy to help!

    control said:
    I am pretty sure that RealTerm works fine. For example, if I send "AT\r\n" I get back "OK" on REalTerm. If I do the same via the ble module I get back "AT\r\n OK ".

    Could you tell me more about how the boards and computer is connected?
    When you say that you are seeing the incorrect "AT\r\n OK " from the BLE module, are you seeing this on an RTT terminal? 

    control said:
    The inner resistor is used for Rx pin. It is achieved by applying the following code after uart_init()- 

    By this, you mean that you are engaging the PULL UP resistor of the RX pin, correct?
    Is there a reason why you are only doing this on the RX pin - is this specified by your cellular modem?
    Could you confirm for me that you are not receiving any errors from your nordic driver functions?
    Please make sure that you perform an APP_ERROR_CHECK on the return values of all nordic driver functions, and that you have DEBUG defined in your preprocessor defines, as shown in the included image:

    control said:
    It is not a secret that our cellular module is SIMCOM 7020 which is connected with ble module via UART. Do you think that I have a problem because I use RTT for logging?

    It should not be a problem no - if your connections are correct, and you are not in fact interfering with your UART communications this way.
    Are you able to see the logger outputs to the RTT "debug terminal" in Segger Embedded Studios?

    control said:
    NRF_LOG_BACKEND_RTT_ENABLED 1

    This is correct, but could you also show me all your other NRF_LOG_* defines?
    If you are building this code on the foundation of the ble_app_uart example then the logger configurations should be fine, since this example uses RTT logging ( since the UART peripheral is used by the application itself ).

    I am looking forward to resolving this issue together!

    Best regards,
    Karl

  • Hi Karl

    thanks for your help. I got a logic analyzer and I tested the response and the problem is on the SIMCOM module. The SIMCOM module sometimes works a little bit weird. Somehow I can manage this but subsequently, I got another problem. When I send AT commands for example multiple times every 10s I got the following error after 20 or 30 iterations.


    00> ------------- Exception called -------------
    00> assert failed: ( portNVIC_INT_CTRL_REG & portVine: 508

    Do you know why this happened?

  • Hello Samo,

    control said:
    I got a logic analyzer and I tested the response and the problem is on the SIMCOM module. The SIMCOM module sometimes works a little bit weird.

    Interesting! What are you seeing on the SIMCOM module - how is it behaving weirdly?
    Are you able to see how it behaves differently when it is connected to either the PC or the nRF?
    Are you able to use the logic analyzer to confirm that both the PC and the nRF sends the same commands over UART? 

    control said:
    When I send AT commands for example multiple times every 10s I got the following error after 20 or 30 iterations.
    control said:
    Do you know why this happened?

    No sorry, I do not immediately recognize this assert.
    Have you defined DEBUG in the preprocessor defines for the COMMON build configuration, like shown in the image included with my previous comment?
    Does the log show anything more than these two lines, such as the location of the triggered assert? 

    Just to make sure, this is the assert outputted by the NRF device when you have sent multiple AT Commands to the cellular modem over UART, with 10 seconds increments between each command. Have I understood this correctly?

    Best regards,
    Karl

  • It seems that the SIMCOM module starts working properly when it is power on at least 10s. If the command is sending before that time it can happen that SIMCOM does not respond at all. It is interesting fact because they stated in the documentation that this time is 2s. I can confirm that PC and nrf send the same commands over UART proved by a logic analyzer.

    If I use DEBUG I get the following error

    assert failed: ( portNVIC_INT_CTRL_REG & portV(ª®ª¢ªªªª
    file: ../../../../../kernel/rtos/FreeRTOS/Source/portable/GCC/mt2625/ARM_CM4F/port.c
    line: 508

    It is very weird that I get this error  because I do not use FreeRTOS operating system.

    Yes, you understand correctly, I send only one command every 10s. I hope that this information will help you.

    Thanks in advance.

Related