Bit 6 of the hours register selects 12 or 24 hours. It should be set for 12 hours. It looks like your code clears it. Then if you are in 12-hour mode, but only then, bit 5 determines whether the current time is PM (set) or AM.
Also, while it looks like you are converting the hour to BCD, I don't see where you convert the value you read back from BDC to a regular value. But I don't have time right now to study your code, so I may have missed this.
Finally, when you write the hours register value, are you ORring in bits 5 and 6 before writing?
Finally finally, in the Arduino world, the DS3231's I2C address is 0x68. I'm confused by the 0xD0.