rtc library with uno vs mega

Have a strange one in that with uno board sketch worked fine.
Now with mega i am finding the sketch delivering different results
i am calling
now = rtc.gettime();

Presumably this returns 3 bytes into now
now.hour , now.minutes , now.sec

i have a routine setting the hour of a Wordclock
sethour( now.min, now.hour );

With Uno it use to work defined as
void sethour( byte p_min , byte p_hour )

switch ( p_hour )
case 1: set the leds to light up the letters "one"
case 18: set the leds to light up the letters "six" ( pm )

whats happenning with mega is the value passed in here for hour is now interpreted as hex value in the switch

eg. for value 18 in hour it is falling into the
case 12: as 12 in hex is 18 and so lighting up letters "twelve"

the fix is easy as i just change the routine header signature to
void sethour( int p_min , int p_hour )

Funny thing is the routine to set the minutes still works as it did

any ideas whats going on ?


Maybe inconsistent data used as consistent data, due to improper wiring (SDA & SCL are pins 20 & 21 on a mega board...) and no error handler within the code?

There should be no difference in how the RTC works on an UNO vs a Mega, unless there are some conditional compiler directives that alter the code based on which board it is being compiled for.

Would help if you can post the code, the problem is likely somewhere else and this is just a side effect of another error.

Also please tell us which of the dozens of RTC libraries you're using.

I am suspecting a hardware/connection issue so i will be swapping out the RTC with another.

i'll report back soon