A couple of other things I question:Please bear in mind I'm not a real programmer just a poor hacker!

You say you set a rate in Protues but don't you have to have those configs to set the chip up to work at that speed even in Proteus?

Once you go through the mainloop you never go back to it. I don't see a line in your code where you have goto mainloop anywhere.

On the write1820 sub, and some others, you write either a 0 or a1 then shift if right 1 digit. Won't that constantly shift in a zero? And in same sub there are 8 bits to a byte but I think they shouldstart at 0 not 1. I don't really understand how that works so if I'm wrong I'll look up the 1820 and get schooled up.