Hi,
I have a variable named g_ullSystemTick, define like this:
This variable increase very 1ms in the timmer ISR.Then i want measure the time my code cost use g_ullSystemTick, there's my code:
Display All
I debug this program, found g_ulMaxCenterSendWaitTime always be 0, and I know that's clearly wrong,it's definitely not going to be 0. So i set a breakpoint at , and i found g_ullSystemTick(the value is 1220) is larger than g_ullStartTick(the value is 1200),but g_ullIntervalTick still equal 0!I don't know what went wrong.
The variables is global variable and use 'volatile' qualifier, and only this function use there variables. My project setting is, Code > Code Generation > Optimization Level set to Debug,Code > Code Generation > Debugging Level set to level-3.
I run this code in keil MDK,very thing is OK.
I don't dare use SES now because i don't know when there will be weird problems even my code work well in keil MDK before.
Is there any way to solve the problem?
I have a variable named g_ullSystemTick, define like this:
This variable increase very 1ms in the timmer ISR.Then i want measure the time my code cost use g_ullSystemTick, there's my code:
Source Code
- volatile uint32_t g_ulMaxCenterSendWaitTime = 0, g_ulMaxCenterSendExcuteTime = 0;
- volatile uint64_t g_ullStartTick = 0, g_ullIntervalTick = 0;
- void function(void)
- {
- //some code
- while (1)
- {
- g_ullStartTick = g_ullSystemTick;
- while (!m_conn_tx_packet_count[pars->peripheral_id])
- {
- if ((pars->timeout) && (!s_ulOperateTimeoutCounter))
- {
- break;
- }
- if ((!g_tBleInterface.ble_connectsta[pars->peripheral_id]) || (m_conn_handle_nus_c[pars->peripheral_id] == BLE_CONN_HANDLE_INVALID))
- {
- return false;
- }
- }
- g_ullIntervalTick = g_ullSystemTick - g_ullStartTick;
- if (g_ullIntervalTick > g_ulMaxCenterSendWaitTime)
- {
- g_ulMaxCenterSendWaitTime = g_ullIntervalTick;
- }
- g_ullStartTick = g_ullSystemTick;
- if (ble_nus_c_string_send(p_ble_nus_c, &txbuf[send_index], factlen) == NRF_SUCCESS)
- {
- g_ullIntervalTick = g_ullSystemTick - g_ullStartTick;
- if (g_ullIntervalTick > g_ulMaxCenterSendExcuteTime)
- {
- g_ulMaxCenterSendExcuteTime = g_ullIntervalTick;
- g_ucMaxTimeCmd = cmd_par->cmd;
- }
- if (m_conn_tx_packet_count[pars->peripheral_id])
- {
- m_conn_tx_packet_count[pars->peripheral_id]--;
- }
- break;
- }
- else if (!m_conn_tx_packet_count[pars->peripheral_id])
- {
- return false;
- }
- }
- }
I debug this program, found g_ulMaxCenterSendWaitTime always be 0, and I know that's clearly wrong,it's definitely not going to be 0. So i set a breakpoint at , and i found g_ullSystemTick(the value is 1220) is larger than g_ullStartTick(the value is 1200),but g_ullIntervalTick still equal 0!I don't know what went wrong.
The variables is global variable and use 'volatile' qualifier, and only this function use there variables. My project setting is, Code > Code Generation > Optimization Level set to Debug,Code > Code Generation > Debugging Level set to level-3.
I run this code in keil MDK,very thing is OK.
I don't dare use SES now because i don't know when there will be weird problems even my code work well in keil MDK before.
Is there any way to solve the problem?
The post was edited 2 times, last by hiqrf3 ().