Speedo/Odo Not Working, CEL On.

Ok, so hello everyone, I'm Nikko. I am new to the forums here, and to Harleys. I recently bought a 2006 Sportster Custom XL1200C, it only had 7800 miles on it when I bought it. Up until this morning, I had no issues aside from the primary chain being a little loose. I took it back to the shop for that and they tightened it up for me.
However, just this morning, while on my way to work, My speedometer and odometer stopped working. The light is still on, and everything still works, except for the speed/mileage. The blinkers still self cancel and all. THEN, after about a mile without the speedo, all of a sudden the check engine light comes on. Does anybody have any idea what could cause this? pictures, or diagrams would be a big help, as I still don't know my way around a bike too well, But I am somewhat mechanically inclined. Thanks in advance guys.

First and fore most you need to check battery cables at both ends for being secured and clean. The check engine light coming on is normal when speedo has quit. If cables are secure and clean then you need to read out the fault codes for direction............

Thank you for your answer. Something odd happened though, After I got to worked and parked it for about 3 hours, I had to leave to go to another location. When I hopped on and took off, the darn speedo/odo was working again. I'm kind of baffled at this. I did check the battery cables and they were not only tight and secure, but also clean, in fact, the terminals and cable ends still look new. I am unsure how to check fault codes though. How do I do that, just for future knowledge? and thanks again.

Thank you for your answer. Something odd happened though, After I got to worked and parked it for about 3 hours, I had to leave to go to another location. When I hopped on and took off, the darn speedo/odo was working again. I'm kind of baffled at this. I did check the battery cables and they were not only tight and secure, but also clean, in fact, the terminals and cable ends still look new. I am unsure how to check fault codes though. How do I do that, just for future knowledge? and thanks again.