⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
gert186
Offline
Last seen:1 year 3 months ago
Joined:2016-04-21 12:59
Storage Problems

Hi,

我have written a code to sample P00, P01, P02 ADC Values.

This code is triggered by codless AT+TMRSTART=0,0,1

The code looks like:

else if(user_compare_cmd("TMRSTART",3,3))
{

uint8_t timer_id = ahtoi((char*)argument_array[0]);
uint8_t指数= ahtoi ((char *) argument_array [1]);
times_seconds= ahtoi((char*)argument_array[2]);

if(index == 0)
codeless_env.tmr[timer_id] = app_easy_timer(ahtoi((char*)argument_array[2]),throw_command0);
else if(index == 1)
codeless_env.tmr[timer_id] = app_easy_timer(ahtoi((char*)argument_array[2]),throw_command1);
else
user_reply(tempstr, false);
if(index < 4)
user_reply(tempstr, true);

// INPUT PINS
GPIO_ConfigurePin((GPIO_PORT)0, (GPIO_PIN)0, INPUT, PID_GPIO, false );
GPIO_ConfigurePin((GPIO_PORT)0, (GPIO_PIN)1, INPUT, PID_GPIO, false );
GPIO_ConfigurePin((GPIO_PORT)0, (GPIO_PIN)2, INPUT, PID_GPIO, false );

// ADC INIT

adc_init(GP_ADC_SE, 0, 0);
}

and in the callback code:
void throw_command0()
{
codeless_env.suppress_response = true;
adc_enable_channel(0);
adc_get_sample();
int length = (int)( sizeof(ADC_values_1) / sizeof(ADC_values_1[0]));
for(int i = 0; i < length; i++ ){
adc_enable_channel(0);
adc_get_sample();
ADC_values_1[i] = adc_get_sample();
adc_enable_channel(1);
adc_get_sample();
ADC_values_2[i] = adc_get_sample();
adc_enable_channel(2);
adc_get_sample();
ADC_values_3[i] = adc_get_sample();
}
for(int i = 0; i < length; i++ ){
arch_printf("%i,%i,%i\r\n",ADC_values_1[i],ADC_values_2[i],ADC_values_3[i]);
}
codeless_env.tmr[0] = app_easy_timer(times_seconds,throw_command0);
codeless_env.suppress_response = false;
}

The Timer restarts itself in the callback function.

我t works fine for a periode of time and the the program crashes.

The arrays are global defined:
int ADC_value_1[30];

if i debug it with IDE Keil and run it may the storage will be full or the adc stops working?
Any ideas where the problem occures?

arch_printf() caused the problem!

Best regards
Gert

Device:
我M_Dialog
Offline
Last seen:3 weeks 3 days ago
Joined:2016-12-06 22:25
Hi gert186,

Hi gert186,

我would recommend using the debugger to figure out where the code is crashing. If you can locate the line of code causing the problem we should be able to help further.

Best regards

我M_Dialog

gert186
Offline
Last seen:1 year 3 months ago
Joined:2016-04-21 12:59
我use the debugger! but the

我use the debugger! but the Problem is that the Uart2 callback function is not reached any more:
static void uart_callback(uint8_t res)
This function deletes the buffer more or less.

So if you call arch_printf() in a loop. The code kills itself. I don't know why!

Best regards
Gert

MHv_Dialog
Offline
Last seen:1 month 2 weeks ago
Staff
Joined:2013-12-06 15:10
Hi Gert,

Hi Gert,

我wonder how many bytes you are sending to the UART. You apparently call the timer function every every 10ms. Are you approaching the UART bitrate of 57k6 bit/s?

Will the code run if you send out only one character as an experiment?

/MHv