Skip to content

Commit 9ceea7a

Browse files
committed
Now reads clock calibration byte
1 parent 939a980 commit 9ceea7a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Atmega_Hex_Uploader/Atmega_Hex_Uploader.ino

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// Version 1.8: Made dates in file list line up. Omit date/time if default (unknown) date used.
1515
// Added "L" command (list directory)
1616
// Version 1.9: Ensure in programming mode before access flash (eg. if reset removed to test)
17+
// Added reading of clock calibration byte (note: this cannot be changed)
1718

1819
/*
1920
@@ -53,7 +54,7 @@
5354

5455
// #include <memdebug.h>
5556

56-
const char Version [] = "1.8";
57+
const char Version [] = "1.9";
5758

5859
// bit banged SPI pins
5960
const byte MSPIM_SCK = 4; // port D bit 4
@@ -118,14 +119,15 @@ enum {
118119
SdFat sd;
119120

120121
// copy of fuses/lock bytes found for this processor
121-
byte fuses [4];
122+
byte fuses [5];
122123

123124
// meaning of bytes in above array
124125
enum {
125126
lowFuse,
126127
highFuse,
127128
extFuse,
128-
lockByte
129+
lockByte,
130+
calibrationByte
129131
};
130132

131133
// structure to hold signature and other relevant data about each chip
@@ -237,6 +239,7 @@ enum {
237239
programAcknowledge = 0x53,
238240

239241
readSignatureByte = 0x30,
242+
readCalibrationByte = 0x38,
240243

241244
readLowFuseByte = 0x50, readLowFuseByteArg2 = 0x00,
242245
readExtendedFuseByte = 0x50, readExtendedFuseByteArg2 = 0x08,
@@ -805,6 +808,7 @@ void getFuseBytes ()
805808
fuses [highFuse] = program (readHighFuseByte, readHighFuseByteArg2);
806809
fuses [extFuse] = program (readExtendedFuseByte, readExtendedFuseByteArg2);
807810
fuses [lockByte] = program (readLockByte, readLockByteArg2);
811+
fuses [calibrationByte] = program (readCalibrationByte);
808812

809813
Serial.print (F("LFuse = "));
810814
showHex (fuses [lowFuse], true);
@@ -814,16 +818,19 @@ void getFuseBytes ()
814818
showHex (fuses [extFuse], true);
815819
Serial.print (F("Lock byte = "));
816820
showHex (fuses [lockByte], true);
821+
Serial.print (F("Clock calibration = "));
822+
showHex (fuses [calibrationByte], true);
817823
} // end of getFuseBytes
818824

819825
void showFuseName (const byte which)
820826
{
821827
switch (which)
822828
{
823-
case lowFuse: Serial.print (F("low")); break;
824-
case highFuse: Serial.print (F("high")); break;
825-
case extFuse: Serial.print (F("extended")); break;
826-
case lockByte: Serial.print (F("lock")); break;
829+
case lowFuse: Serial.print (F("low")); break;
830+
case highFuse: Serial.print (F("high")); break;
831+
case extFuse: Serial.print (F("extended")); break;
832+
case lockByte: Serial.print (F("lock")); break;
833+
case calibrationByte: Serial.print (F("clock")); break;
827834
} // end of switch
828835
} // end of showFuseName
829836

0 commit comments

Comments
 (0)