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

uart communication problem !!

am using nrf51822 chip communicating with PIC16fl1509 through uart.the PIC will send the temperatire values through uart to nrf51822. i have a doubt ! will the uart communication only works after advertising ??? can i read the values before advertising and store in an array ,later diaplay during advertising ????will the uart reading functions from pic will work before all the basic functions like ble_stack_init();bond_manager_init();gap_params_init();advertising_init();services_init(); application_timers_start(); advertising_start()etc?? am trying to use uartget data before these but its storing zero in the array !! wats is the problem ?? !! pls help !!

    1. You should look at Nordics simple UART example provided as part of their SDK it will answer a lot of your question. The UART will work before advertising.

    2. You can read values and later display them during advertising, you can put them in the manufacturers specific data in the advertising packet.

    3. The UART is independent of the ble functions of the chip and the associated soft device stack.

    4. It is impossible to know what your problem would be without more information and seeing your code.

  • here is the snippet of code. without using delay am getting only zeros.if i use delay am getting atleast one byte of data under manufactur field !! . is the problem with nrf51 uart ?? because after pairing am getting the temperature data!!

    initVaribles(); simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);

    	 {
    
    	NVIC_EnableIRQ(UART0_IRQn);	
               nrf_delay_us(2000000);
        TaskGetDataFromPIC();
              nrf_delay_us(2000000);
         NVIC_DisableIRQ(UART0_IRQn);
    
               }
    //leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    //data from pic 	
    
    ble_stack_init();
    bond_manager_init();
    gap_params_init();
    
    services_init();
    sensor_sim_init();
    conn_params_init();
    sec_params_init();
    advertising_init();
    
    // Start execution.
    application_timers_start();
    advertising_start();
    
    NVIC_EnableIRQ(UART0_IRQn);	
    //NVIC_DisableIRQ(UART0_IRQn);	
    for (;;)
    {
    		power_manage();
    	  TaskGetDataFromPIC();
    	  TaskAckPic();	
    	
    
    		
    	}	
    
    		
    	}
    
  • All of this may be outside of your snippet, but where is the UART configuration? Things like pin configuration, baud rate, flow control, enabling the device etc.?

  • Those are defined in simple_uart file. Actually am getting temperature value after bonding! but wen i use the same function before advertising init am getting zero values in manufacture field.I added scanned response data as manufacture data in advertising init function !

Related