Hello,
I am working with serial communication interrupt in LPC1768. In that I am receiving a three parameter data in the form of string as X:2341Y:114Z:75 via serial interrupt.
After receiving I am splitting this string and storing 2341 in array1[],114 in array2[] and 75 in array3[] and converting into integer and using in the main function as follows.
int main(){ .... .... .... while(1){ cut_count = (((int)(cut_preset_value[0]-0x30)*1000)+((int)(cut_preset_value[1]-0x30)*100)+((int)(cut_preset_value[2]-0x30)*10)+((int)(cut_preset_value[3]-0x30))); duty_count = (((int)(duty_cycle_value[0]-0x30)*10)+((int)(duty_cycle_value[1]-0x30))); TOTAL_TIME = ceil((ONE_MIN_IN_MSEC)/(cut_count)); //ceil func. is to round off the value dividend_value = ((TOTAL_TIME)*(duty_count)); ON_TIME_VALUE = ceil(dividend_value/PERCENT_DIVISOR_VALUE); //ceil func. is to round off the value OFF_TIME_VALUE = ceil(((TOTAL_TIME)-(ON_TIME_VALUE))); //ceil func. is to round off the value
} }
Note:Here cut_preset_value[],suction_preset_value[] and duty_cycle_value[] are the three globally defined arrays for storing values.
Within the while loop the arrays are not updating without board reset.
kindly provide some solution for this. Thank you.
Supply the solution for what?
And I'm not sure your "converting to integer" is the correct thing - have you first converted from string to a number before storing the value in the array? And does the array have a data type suitable for the task? So why do you then need a type cast (int)?
Hi WesterMark,
have you first converted from string to a number before storing the value in the array?
Because the RBR is 8-bit the string values are stored in byte-wise as ascii data in array locations 0,1,2 and 3. And those ascii values are converting into integer in main fn. with the step,
cut_count=(((int)(cut_preset_value[0]-0x30)*1000)......
and working properly for first time interrupt. And if the interrupt occurs second time and so on the values are not get updated.
does the array have a data type suitable for the task
Yes I am defined the array as "uint8_t" and as "global variable"..
why do you then need a type cast (int)?
Its not needed over there.Just for taking the integer value if (cut_preset_value[0]-0x30) doesn't works.