This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Trouble passing 32-bit parameter

Hi,

I am experiencing trouble passing a 32-bit variable to a subroutine. Here's a snippet of the code:

void mainChargingRoutine(void)
{

    static uint32_t firstBattVal;

    ......

    analysisComplete = chargeRateAnalysis(firstBattVal, chargingMins, chargingTimer);

uint16_t chargeRateAnalysis(uint32_t begBattVal, uint16_t chrgMins, int16_t chrgTimer)
{

    //do stuff


What is happening is that when the function "mainChargingRoutine" calls "chargeRateAnalysis", it passes the 32-bit local variable called "firstBattVal." Inside the "chargeRateAnalysis" function its value should be available in the begBattVal, which is also declared as an unsigned 32-bit value.
However, the problem is that when I use the debugger to check the values of these variables, I see that as soon as the "chargeRateAnalysis" function is called, the value for begBattVal is being truncated to a 16 bit version of "firstBattVal."
Since it is declared as an unsigned 32-bitt variable in all the relavent locations, why would it be truncated like that?

Let me know if I can provide any more information to help solve this question.

Thanks!