Skip to main content

Storage Problems

2 years ago

Storage Problems

Posted bygert1860 points 3 replies
0 upvotes

Hi,

I 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();
一个DC_values_1[i] = adc_get_sample();
adc_enable_channel(1);
adc_get_sample();
一个DC_values_2[i] = adc_get_sample();
adc_enable_channel(2);
adc_get_sample();
一个DC_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.

It 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?
一个ny ideas where the problem occures?

arch_printf() caused the problem!

Best regards
Gert

2 years ago

IM_Dialog

Hi gert186,

I 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

IM_Dialog

2 years ago

gert186 0 points

I 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

2 years ago

MHv_Dialog

Hi Gert,

I 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