Hi
I have in my application two functions which I call from main, called
void write() and void ArrayFill(), which I can call from main() and operating as expected.
I also have a function called defaultFunction which takes a number of parameters
Code:
defaultFunction(mult_ptr, tenMinCount_ptr, hourCount_ptr, ee_addr01, ee_addr02, hours_array_ptr);
and I want to call write() and ArrayFill() from there, but they do not operate as I would expect. This is what my defaultFunction looks like
Code:
void defaultFunction(uint8_t *multPtr, uint8_t *tenmin_ptr, uint32_t *hrcount_ptr, uint8_t *e2p_add01, uint8_t *e2p_add02, uint8_t *hrsarr)
{
//uint32_t RTC_Val = *rtcPtr;
uint32_t hours_count = *hrcount_ptr;
uint8_t multiple = *multPtr;
uint8_t tenMin_count = *tenmin_ptr;
uint8_t eep_add01 = *e2p_add01;
uint8_t eep_add02 = *e2p_add02;
uint8_t hr_arr_ptr = *hrsarr;
GPIO_SetBits(GPIOB, GPIO_Pin_2); // set the PCH power control ON
RTC_SetCounter(0);
while(1)
{
uint32_t RTC_counter = RTC_GetCounter();
IWDG_ReloadCounter(); // reset IWDG timer to 0x186A (10 secs)
if ((multiple > 6) || (tenMin_count > 5))
{
multiple = 1;
tenMin_count = 0;
}
if (RTC_counter == (600 * multiple)) // triggers at 600,1200,1800,2400 seconds
{
tenMin_count++; // increment ten minute counter
multiple++; // increment multiplier value
EEPROMWrite(multiple, tenMin_count, eep_add01, eep_add02);
}
if (RTC_counter == 3600) // triggers each hour
{
hours_count++; // increment hours counter
tenMin_count = 0; // reset ten minute count
multiple = 1; // reset multiplier
RTC_SetCounter(0);
numArrayFill(hr_arr_ptr, hours_count, sizeof(hours_array));
}
}
}
Why would the call from this function operate differently than a call from main? This code is a duplicate of a section of main, so I am expecting its the way I have called my parameters, but I can't work out where I have gone wrong.
Thanks
Dave