-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Microsoft has finally fixed Windows 11 May Patch Tuesday install issues
By Usama Jawad96,
- microsoft
- windows 11
- (and 8 more)
- 2 replies
- 0 views
-
Microsoft confirms Domain Controller bug in Windows Server 2016
By Usama Jawad96,
- microsoft
- windows server
- (and 8 more)
- 7 replies
- 0 views
-
Microsoft blames macOS for annoying Teams bug
By Usama Jawad96,
- microsoft
- microsoft teams
- (and 6 more)
- 1 reply
- 0 views
-
Windows 11 KB5083769 update breaks BITS and causes system freezes
By zikalify,
- microsoft
- windows 11
- (and 6 more)
- 7 replies
- 0 views
-
The "Windows bug" that mysteriously crashed File Explorer
By Usama Jawad96,
- 9 replies
- 0 views
-
Question
n_K
Right, I don't know if I'm being stupid or what but I'm reading the time from an RTC chip via I2C and storing it in an array, and then processing it as below... For some reason, Data[8] shows the seconds fine but Data[0] always shows 0, but I can't really see why? Am I doing something wrong or is this a bug?
while (i < 7) { IdleI2C(); Data[i] = ReadI2C(); ++i; } Data[8] = Data[0] & 0b01111111; Data[0] = Data[0] & 0b01111111; //Seconds Data[1] = Data[1] & 0b01111111; //Minutes Data[2] = Data[2] & 0b01111111; //Hours Data[3] = Data[3] & 0b00000111; //Days Data[4] = Data[4] & 0b00111111; //Date Data[5] = Data[5] & 0b00011111; //Month Data[6] = Data[6] & 0b00011111; //Year Data[7] = Data[7] & 0b00011111; //Control Data[0] = ((Data[0] & 0b01110000)>>4)*10 + (Data[0] & 0b00001111); Data[1] = ((Data[1] & 0b01110000)>>4)*10 + (Data[1] & 0b00001111); if ((Data[2] & 0b01000000) == 0b01000000) { //24 hour Data[2] = ((Data[2] & 0b00110000)>>4)*10 + (Data[2] & 0b00001111); } else { //12 hour Data[2] = ((Data[2] & 0b00010000)>>4)*10 + (Data[2] & 0b00001111); } Data[4] = ((Data[4] & 0b00010000)>>4)*10 + (Data[4] & 0b00001111); Data[5] = ((Data[5] & 0b00010000)>>4)*10 + (Data[5] & 0b00001111); Data[6] = ((Data[6] & 0b11110000)>>4)*10 + (Data[6] & 0b00001111); Data[8] = ((Data[8] & 0b01110000)>>4)*10 + (Data[8] & 0b00001111); sprintf(Bob, "%d%c", Data[2], 128); LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[1], 128); LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[0], 128); //Always shows 0 LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[8], 128); //Shows seconds correctly LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[0], 128); //Again, always shows 0 LCDWriteString(&Bob); LCDPosition(2); //Goes to 2nd line sprintf(Bob, " %d%c", Data[3], 128); LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[4], 128); LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[5], 128); LCDWriteString(&Bob); sprintf(Bob, ":%d%c", Data[6], 128); LCDWriteString(&Bob); sprintf(Bob, ",%d%c", Data[8], 128); LCDWriteString(&Bob); LCDPosition(1); //Goes back to first lineLink to comment
https://www.neowin.net/forum/topic/1140794-mplabx-xc16-bug/Share on other sites
2 answers to this question
Recommended Posts