<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Need one stable UART and RTT loging example code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54303/need-one-stable-uart-and-rtt-loging-example-code</link><description>Hi, 
 Overview: In our board BMD340 (containing nRF52840) module present with GSM module and they exchange data using UART(PINRX-6,PINTX-7). Now we trying to use &amp;quot;ble_app_uart&amp;quot; example code from &amp;quot;nRF5_SDK_15.0.0_a53641a&amp;quot;. 
 
 Objective: Using uart we</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Nov 2019 12:58:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54303/need-one-stable-uart-and-rtt-loging-example-code" /><item><title>RE: Need one stable UART and RTT loging example code</title><link>https://devzone.nordicsemi.com/thread/221074?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2019 12:58:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68d610ce-cde1-4b17-aa15-cda21c522e4e</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. When do you get the &lt;strong&gt;Could not start CPU core. (ErrorCode: -1) &lt;/strong&gt;error message? It doesn&amp;#39;t make sense that you are getting it when you sent something over UART.&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Can you explain a bit more about what is happening right before you get this error?&lt;/p&gt;
&lt;p&gt;Can you also try to run a debug session in SES and see if the code is getting stuck anywhere? Try setting a breakpoint in uart_event_handle() and see if you get any callbacks.&lt;/p&gt;
&lt;p&gt;If you are using the UART module in the applicatio you should not use the UART module for logging, so can you also make sure you don&amp;#39;t have the UART backend for logging enable in sdk_config.h?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need one stable UART and RTT loging example code</title><link>https://devzone.nordicsemi.com/thread/220106?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2019 14:27:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07280990-798c-4bec-93aa-8c5418a02514</guid><dc:creator>Phalguni</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am able to compile code, buid &amp;amp; run . But its crash when we sending &amp;quot;AT\r&amp;quot; or other command..for example:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;app_uart.h&amp;quot;

#include &amp;quot;app_util_platform.h&amp;quot;

#include &amp;quot;nordic_common.h&amp;quot; 

#include &amp;quot;nrf_gpio.h&amp;quot;

#include &amp;quot;nrf.h&amp;quot;

#include &amp;quot;nrf_delay.h&amp;quot;

//#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;

#include &amp;lt;stdint.h&amp;gt;

#include &amp;lt;string.h&amp;gt;

 

#if defined(UART_PRESENT)

#include &amp;quot;nrf_uart.h&amp;quot;

#endif

#if defined(UARTE_PRESENT)

#include &amp;quot;nrf_uarte.h&amp;quot;

#endif

 

//#include &amp;quot;nrf_log.h&amp;quot;

//#include &amp;quot;nrf_log_ctrl.h&amp;quot;

//#include &amp;quot;nrf_log_default_backends.h&amp;quot;

//

 

 

#define DEAD_BEEF 0xDEADBEEF /**&amp;lt; Value used as error code on stack dump, can be used to identify stack location on stack unwind. */

 

#define UART_TX_BUF_SIZE 512  /**&amp;lt; UART TX buffer size. */

#define UART_RX_BUF_SIZE 512 /**&amp;lt; UART RX buffer size. */

//modempin define

#define modemVCCEnablePin 23     // Power gating modem and codec

#define modemShifterEnablePin 20 // Uart level shifter

#define eSIMsel 21 // Uart level shifter

#define modemRxPin 6

#define modemTxPin 7

#define modemPwrOnPin 12

#define modemResetPin 22

//#define paShutdownPin   13 // CODECIRQ?!?!? what is this? connected to Codec IRQ pin

#define RESP_OK 1           //RESP_OK for modem return

#define SIM_READY 2         //SIM READY

 

uint8_t gsm_data_array[120];

uint8_t gsm_index = 0;

uint8_t icount=0,tx_flag=0;

 

void peripheralsPowerOn(bool allPeripherals);

void peripheralsPowerOff();

void GSM_powerON();

void gsm_read();

void wait();

void wait_ms();

void wait_us();

int waitFinalResp();

int gsm_init();

void sendFormated(const char* str);

int modem_internet();

 

 


void uart_event_handle(app_uart_evt_t *p_event) {

  uint32_t err_code;

  switch (p_event-&amp;gt;evt_type) {

  case APP_UART_DATA_READY:

     err_code=app_uart_get(&amp;amp;gsm_data_array[gsm_index]);

     gsm_index++;

     if (gsm_data_array[gsm_index-1]== &amp;#39;\r&amp;#39;) {

     gsm_index=0;

     }

 

    break;

 

  case APP_UART_COMMUNICATION_ERROR:

    APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);

    break;

 

  case APP_UART_FIFO_ERROR:

    APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);

    break;

 

  default:

    break;

  }

}

 

static void uart_init(void) {

  uint32_t err_code;

  app_uart_comm_params_t const comm_params =

      {

          .rx_pin_no = 6,

          .tx_pin_no = 7,

          .rts_pin_no = UART_PIN_DISCONNECTED,

          .cts_pin_no = UART_PIN_DISCONNECTED,

          .flow_control = APP_UART_FLOW_CONTROL_DISABLED,

          .use_parity = false,

          .baud_rate = NRF_UART_BAUDRATE_115200

      };

  APP_UART_FIFO_INIT(&amp;amp;comm_params,

      UART_RX_BUF_SIZE,

      UART_TX_BUF_SIZE,

      uart_event_handle,

      APP_IRQ_PRIORITY_LOWEST,

      err_code); 

  //NRF_LOG_INFO(&amp;quot;error code %d&amp;quot;, err_code);

  APP_ERROR_CHECK(err_code);

}


static void log_init(void) {

  ret_code_t err_code = NRF_LOG_INIT(NULL);

  APP_ERROR_CHECK(err_code); 

  NRF_LOG_DEFAULT_BACKENDS_INIT();

}

 static void power_management_init(void) {

  ret_code_t err_code;

  err_code = nrf_pwr_mgmt_init();

  APP_ERROR_CHECK(err_code);

}

 

static void idle_state_handle(void) {

  UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());

  nrf_pwr_mgmt_run();

}

 

//delay for modem

void wait_ms(uint32_t time_ms){

 nrf_delay_ms(time_ms);

}

 

void wait_us(uint32_t time_us){

  nrf_delay_us(time_us);

}

 

void wait(uint32_t time_s){

  nrf_delay_ms(time_s*1000);

}

 void Modem_reset() {

   nrf_delay_ms(20);

  nrf_gpio_cfg_output(modemResetPin);

  nrf_gpio_pin_clear(modemResetPin);

  nrf_delay_ms(20);

  nrf_gpio_cfg_input(modemResetPin, NRF_GPIO_PIN_NOPULL);

  nrf_delay_ms(20);

}

void GSM_powerON(){

//power on

    nrf_gpio_cfg_output(modemPwrOnPin);

    nrf_gpio_pin_clear(modemPwrOnPin);

    nrf_delay_us(65);

    nrf_gpio_cfg_input(modemPwrOnPin, NRF_GPIO_PIN_NOPULL);

    nrf_delay_ms(10);

}

void peripheralsPowerOn(bool allPeripherals) {

  if (allPeripherals) {

    nrf_gpio_cfg_output(eSIMsel); 

    nrf_gpio_pin_set(eSIMsel);              //seim two selected

    nrf_delay_ms(10);

   

    nrf_gpio_cfg_output(modemVCCEnablePin); // MODEM + CODEC

    nrf_gpio_pin_set(modemVCCEnablePin);    // 2.7ms turn-on rise time

    nrf_delay_ms(10);

 

    nrf_gpio_cfg_output(modemShifterEnablePin); // MODEM level shifter

    nrf_gpio_pin_clear(modemShifterEnablePin);

    nrf_delay_us(100);

    GSM_powerON();

  }

}

 

void peripheralsPowerOff(void) {

  nrf_gpio_cfg_output(modemShifterEnablePin); // MODEM level shifter

  nrf_gpio_pin_set(modemShifterEnablePin);

  nrf_gpio_cfg_output(modemVCCEnablePin); // MODEM + CODEC

  nrf_gpio_pin_clear(modemVCCEnablePin);

}



void sendFormated(const char* str) {

     app_uart_put(&amp;#39;\r&amp;#39;);

     wait_ms(20);

     uint32_t len = strlen((uint8_t *)str);

     for (uint32_t i = 0; i &amp;lt; len; i++) { 

          app_uart_put(str[i]) ;    

           wait_ms(20);

      }

    wait_ms(300);

}

 


void SMS_SEND()

{

      sendFormated(&amp;quot;AT+CMGF=1\r\n&amp;quot;);

      sendFormated(&amp;quot;AT+CMGS=\&amp;quot;09004061579\&amp;quot;\r\n&amp;quot;);

      wait(30);

      sendFormated(&amp;quot;hello&amp;quot;);

      app_uart_flush();

      while(app_uart_put((uint8_t)0x1A));

      wait_ms(7000);             

}

int modem_internet(){

        

      sendFormated(&amp;quot;AT+CFUN=1\r&amp;quot;); 

      sendFormated(&amp;quot;AT+CSQ\r&amp;quot;);

      sendFormated(&amp;quot;AT+COPS\?\r&amp;quot;);

      sendFormated(&amp;quot;AT+CGREG\?\r&amp;quot;);

      // SMS_SEND();

      sendFormated(&amp;quot;AT+CMEE=1\r&amp;quot;);

      //sendFormated(&amp;quot;AT+CGACT=1\r&amp;quot;);

      sendFormated(&amp;quot;AT+CGDCONT=1,\&amp;quot;IP\&amp;quot;,\&amp;quot;internet.gma.iot\&amp;quot;\r&amp;quot;);

      sendFormated(&amp;quot;AT+CGACT=1,1\r&amp;quot;);

      sendFormated(&amp;quot;AT+CGPADDR=1\r&amp;quot;);

}

int modem_init(){

   sendFormated(&amp;quot;AT\r&amp;quot;);

   sendFormated(&amp;quot;ATE0\r&amp;quot;);

   sendFormated(&amp;quot;AT&amp;amp;K0\r\n&amp;quot;);

   sendFormated(&amp;quot;AT+UGPIOC=23,255\r&amp;quot;); // GPIO2

   sendFormated(&amp;quot;AT+UGPIOC=24,255\r&amp;quot;); // GPIO3

   sendFormated(&amp;quot;AT+IPR=115200\r&amp;quot;);

   sendFormated(&amp;quot;AT+CCID\r&amp;quot;);

   sendFormated(&amp;quot;AT+CLIP=1\r&amp;quot;);

   sendFormated(&amp;quot;AT+CRC=1\r&amp;quot;);  

 }

int main(void) {

      

      peripheralsPowerOn(true);

      power_management_init(); 

       uart_init();

       log_init();

       NRF_LOG_INFO(&amp;quot;init done&amp;quot;);

      UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());

      sendFormated(&amp;quot;AT\r&amp;quot;);

   sendFormated(&amp;quot;ATE0\r&amp;quot;);

   sendFormated(&amp;quot;AT&amp;amp;K0\r&amp;quot;);   

        modem_init();

        modem_internet();

        for (;;) {

         idle_state_handle();

        }

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in this uart code i am using &amp;quot;&lt;span&gt;APP_UART_FIFO_INIT&amp;quot; &lt;strong&gt;so my&amp;nbsp;question is there any other way we can write code which using HAL ?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I attached circuit diagram of BMD340 for reference&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1573741155113v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need one stable UART and RTT loging example code</title><link>https://devzone.nordicsemi.com/thread/220078?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2019 13:19:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fa8db42-761a-42dc-8e3f-f815ed871d84</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;So you are not able to compile and debug any example on the SDK? Can you describe how things are connected? How is the j-link EDU connected to the BMD340 module? And how is the BMD340 being powered? If you could attach a picture of the setup and the schematic files of your PCB it would be great.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need one stable UART and RTT loging example code</title><link>https://devzone.nordicsemi.com/thread/220044?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2019 10:31:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19842776-f3f8-4510-88b6-5df14b4c1590</guid><dc:creator>Phalguni</dc:creator><description>&lt;p&gt;We are using &amp;gt;&amp;gt;Environment: IDE- Segger embedded studio, external Debugger- segger-jlink EDU, Hardware- development board, SDK version -&amp;quot;nRF5_SDK_15.0.0&amp;quot;&lt;/p&gt;
&lt;p&gt;Use of BMD340 is send AT command to GSM and some internal sensor data capturing&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We able to compile and debugging &amp;quot;sometime&amp;quot; and crash.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i try with&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/uart_example.html?cp=6_1_4_6_50"&gt;UART hardware peripheral example&lt;/a&gt;&amp;nbsp;but no luck. problem in sending and receiving data handling so let me any help you can do&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need one stable UART and RTT loging example code</title><link>https://devzone.nordicsemi.com/thread/220040?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2019 10:16:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95f1af32-9260-4b17-90ca-4a9a0b65234d</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi Oliver,&lt;/p&gt;
&lt;p&gt;If I understood correctly you want to send messages from the nRF52840 module (BMD340) to a GPS module via the UART peripheral?&lt;/p&gt;
&lt;p&gt;I recommend you take a look at the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/uart_example.html?cp=6_1_4_6_50"&gt;UART hardware peripheral example&lt;/a&gt;, under the folder \examples\peripheral\uart in the SDK.&lt;/p&gt;
&lt;p&gt;RTT logging can you enable in sdk_config.h by setting NRF_LOG_BACKEND_RTT_ENABLED to 1.&lt;/p&gt;
&lt;p&gt;But are you sure you are able to compile and run the examples in the SDK at all? From the error messages you are getting it seems like you have some HW issue. What do you use to program the BMD340 module? Are you using an external debugger or the debugger on a DK perhaps? And do you program using nrfprog or SES?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>