Skip to main content

Hibernation mode

1 month ago

Hibernation mode

Posted byvishaliotlynx20 points 5 replies
0 upvotes

hi all,

I am working on DA14531 tiny module.I want to put my device in hibernate mode for that i done following changes in barebone.c file

static void enter_ship_mode(void)
{
arch_printf("\n\r%s", __FUNCTION__);

/* Ensure all debug output is complete before entering ship mode */
arch_printf_process();
while(GetBits32(UART2_USR_REG, UART_BUSY) != 0);

/* Put device into hibernation mode with no RAM retained (cold boot on wakeup)
function DOES NOT RETURN */
arch_set_hibernation(0x20, /* P0_5 */
PD_SYS_DOWN_RAM_OFF,
PD_SYS_DOWN_RAM_OFF,
PD_SYS_DOWN_RAM_OFF,
REMAP_ADDR0_TO_ROM,
false);
}
static void flash_power_down(void)
{
arch_printf("\n\r%s", __FUNCTION__);
/* Default SPI configuration */
static const spi_cfg_t spi_cfg = {
.spi_ms = SPI_MS_MODE_MASTER,
.spi_cp = SPI_CP_MODE_0,
.spi_speed = SPI_SPEED_MODE_4MHz,
.spi_wsz = SPI_MODE_8BIT,
.spi_cs = SPI_CS_0,
.cs_pad.port = SPI_EN_PORT,
.cs_pad.pin = SPI_EN_PIN,
.spi_capture = SPI_MASTER_EDGE_CAPTURE,
};

/* Initialize interface to SPI flash */
spi_initialize(&spi_cfg);

/* Disable HW RST on P0_0 so it can be used as SPI MOSI */
GPIO_Disable_HW_Reset();
spi_flash_power_down();

/* Re-enable HW reset input (must be disabled if/when further operations on
external flash are performed) - must set as input first! */
GPIO_ConfigurePin(SPI_DO_PORT, SPI_DO_PIN, INPUT_PULLDOWN, PID_GPIO, false);
GPIO_Enable_HW_Reset();
}
uint8_t count_var = 0;
void user_app_adv_undirect_complete(uint8_t status)
{


字符缓冲区[2],str_parse [5];
arch_printf("\n\r%s", __FUNCTION__);
while(uart_data_ready_getf(UART1) == 1)
{
uart_receive(UART1, (uint8_t *)buffer, 1, UART_OP_BLOCKING);
//uart_write_byte(UART2,buffer[0]);
rx_buff[count] = buffer[0];
count++;
}
while(uart_data_ready_getf(UART1) == 1)
{
uart_receive(UART1, (uint8_t *)buffer, 1, UART_OP_BLOCKING);
//uart_write_byte(UART2,buffer[0]);
rx_buff[count] = buffer[0];
count++;
}

rx_buff[count] = '\0';
strncpy(str_parse,rx_buff+4,2);
temp_val = atoi(str_parse);
uart_write_byte (UART1,temp_val);
memset(str_parse,0,sizeof(str_parse));


strncpy(str_parse,rx_buff+8,4);
supply_vtg_vale = atoi(str_parse);
uart_write_byte (UART2,supply_vtg_vale & 0xFF);
uart_write_byte (UART2,supply_vtg_vale >> 8);
memset(str_parse,0,sizeof(str_parse));

strncpy(str_parse,rx_buff+13,2);
pressure_value = atoi(str_parse);
uart_write_byte (UART2,pressure_value);
memset(str_parse,0,sizeof(str_parse));

//uart_write_byte(UART1,'D');
// uart_write_byte(UART1,count);
// uart_write_byte(UART1,'\r');
// uart_write_byte(UART1,'\n');
// for(int i=0; i// uart_write_byte(UART1,rx_buff[i]);
// count =0;
// memset(rx_buff,0,sizeof(rx_buff));
// uart_write_byte(UART1,'\r');
// uart_write_byte(UART1,'\n');
// If advertising was canceled then update advertising data and start advertising again

count_var++;

if (status == GAP_ERR_CANCELED)
{
user_app_adv_start();

}

if (count_var > 2)
{
uart_write_byte (UART2,'A');
count_var = 0;
//arch_printf("\n\r%d",count_var);

flash_power_down();
__nop();
__nop();
__nop();
__nop();
enter_ship_mode();
}



}

so after adding that code my code is not working

also i tried to reprogram flash smartbond flash programmer shows below error

No chip found while opening JLINK connection terminating process......

i also tried to put using single wire uart programming using smartsnippet toolbox but i not get succed.

what i do for hibernation mode ?? my code is correct

i lost 4 hw when i programming flash.so how i recover that hw??

1 month ago

PM_Dialog

Hi vishaliotlynx,

Thanks for your question online and for your interest in our TINY module solution.

I would recommend first checking theDA14531 Configuring Hibernation and State-aware hibernation modeSW Example. The DA14531 is going into hibernation when the advertising is off and the user_app_adv_undirect_complete() fires up. Regarding your code snippet :

1. Did you run your code in debug mode before burning the flash so that you can check if it is working fine? In the user_app_adv_undirect_complete() I saw that you would like to read some data via UART. So, if the WDOG is enabled, I guess the WDOG times out and the code gests stack in the NMI handler.

So, my first suggestion would be to boot from System-RAM, attach the debugger, add some breakpoints and check if the code is running properly.

For example, if you add a break point into enter_ship_mode(), does it hit?

2. In the user_app_adv_undirect_complete(), if the status is GAP_ERR_CANCELED, the advertising is re-started. I assume that the code never reach the enter_ship_mode(); due to #1.

3. If the SPI flash is programmed, I believe that the chip is always resetting because the code might get stack into an assertion, NMI etc., so you are not allowed to connect to the SPI Flash.

4. Please try to boot from System-RAM using the ble_app_barebone project as provided by the SDK. When the devices boots, connect to the SPI Flash using the toolbox and erase it.

Thanks, PM_Dialog

1 month ago

vishaliotlynx 20 points

hi ,

thanks for your response

in that code snippet you see that i put some serial debug statements that run succesessfully.

my flow is as bellow

1) DA14531 it read some byte from UART

2) advertise that byte over ble

3)after advertising it goes into hibernation

4) from GPIO P0_5 its wakeup do above steps again.

here i check with ble barebone example i receive data thorugh uart and advertise over ble

for hibernation i have issue so what i do ??

1 month ago

PM_Dialog

Hi vishaliotlynx,

Apologies for the delay.

Please add a breakpoint inside the enter_ship_mode() in line where the arch_set_hibernation() is called.

Run your project in debug mode.

Does the breakpoint hit?

It would be very helpful if you can provide some debugging information so that I can understand what is getting wrong.

Thanks, PM_Dialog

1 month ago

vishaliotlynx 20 points

my hibernation code is working now.

now i want to change initial advertising data

i done folowing changes in ble barebone example

#define USER_ADVERTISE_DATA ""
/// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set
#define USER_ADVERTISE_DATA_LEN (sizeof(USER_ADVERTISE_DATA)-1)

/ / /扫描响应nse data
#define USER_ADVERTISE_SCAN_RESPONSE_DATA ""

/ / /扫描响应nse data length- maximum 31 bytes
#define USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN (sizeof(USER_ADVERTISE_SCAN_RESPONSE_DATA)-1)

char adv_data[10] = {0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc};
void user_app_init(void)
{

arch_printf("\n\r%s", __FUNCTION__);
app_param_update_request_timer_used = EASY_TIMER_INVALID_TIMER;

// Initialize Manufacturer Specific Data
mnf_data_init();

// Initialize Advertising and Scan Response Data
memcpy(stored_adv_data, adv_data, 10);
//memcpy(stored_adv_data, USER_ADVERTISE_DATA, USER_ADVERTISE_DATA_LEN);
stored_adv_data_len = 8;
memcpy(stored_scan_rsp_data, USER_ADVERTISE_SCAN_RESPONSE_DATA, USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN);
stored_scan_rsp_data_len = USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN;

default_app_on_init();
}

so it cant show my data in advertising of ble

1 month ago

PM_Dialog

Hi vishaliotlynx,

Glad that that hibernation code is working now. The advertising data should follow a specific format – please check the following tutorial for more information :

http://lpccs-docs.dialog-semiconductor.com/DA145xx_Advertising_Tutorial/changing_advertising_parameters.html#changing-the-advertising-data

The USER_ADVERTISE_DATA are mem-copied into the advertising string in app_easy_gap_undirected_advertise_start_create_msg() function. You can modify the USER_ADVERTISE_DATA macro in order to change the advertising data.

Since this issue is not related to the initial post, I would recommend creating a new one.

Thanks, PM_Dialog