diff --git a/.gitignore b/.gitignore
index b4732b7..f8c3f19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -69,3 +69,4 @@
/kelvin_ntc.X/nbproject/*.mk
/kelvin_ntc.X/nbproject/Package-Debug_2580.bash
/kelvin_ntc.X/nbproject/Package-Relocated_2580.bash
+/kelvin_ntc.X/dist/Relocated_26K80/
\ No newline at end of file
diff --git a/kelvin_ntc.X/funclist b/kelvin_ntc.X/funclist
index af3d5bf..4d07fed 100644
--- a/kelvin_ntc.X/funclist
+++ b/kelvin_ntc.X/funclist
@@ -1,108 +1,153 @@
-_vscp_getBootLoaderAlgorithm: CODE, 24548 0 2
-___asflsub: CODE, 22406 0 78
-_vscp_getZone: CODE, 24474 0 10
-_vscp_getControlByte: CODE, 24050 0 32
-_log: CODE, 18156 0 302
-_init: CODE, 23248 0 60
-_vscp_setManufacturerId: CODE, 24172 0 28
-exp@coeff: SMALLCONST, 2848 0 40
-___aldiv: CODE, 20054 0 188
-_ECANReceiveMessage: CODE, 15312 0 526
-_vscp_getEvent: CODE, 23750 0 42
-___flmul: CODE, 19266 0 214
-_vscp_handleHeartbeat: CODE, 24556 0 2
-_vscp_readRegister: CODE, 24228 0 26
-_vscp_setGUID: CODE, 23870 0 38
-_sendTempEvent: CODE, 21534 0 132
-__RegsToCANID: CODE, 17112 0 356
-_vscp_deviceURL: SMALLCONST, 2816 0 32
-_vscp_writeRegister: CODE, 23982 0 34
-_getVSCPFrame: CODE, 21796 0 120
-i1_ConvertADC: CODE, 24540 0 4
-_vscp_setControlByte: CODE, 23908 0 38
-_vscp_getUserID: CODE, 24370 0 20
-_setEventData: CODE, 20424 0 176
-_Celsius2Kelvin: CODE, 23424 0 52
-_Busy_eep: CODE, 24522 0 6
-_vscp_error: CODE, 24528 0 4
-_doWork: CODE, 14204 0 1108
-_getCalibrationValue: CODE, 23064 0 62
-_vscp_init_pstorage: CODE, 24532 0 4
-___fltol: CODE, 21092 0 158
-_vscp_restoreDefaults: CODE, 24514 0 8
-___flsub: CODE, 23188 0 60
-___flge: CODE, 22484 0 76
-_vscp_readStdReg: CODE, 16322 0 432
-_vscp_readAppReg: CODE, 8716 0 1964
-_vscp_getFamilyCode: CODE, 24494 0 10
-_vscp_setUserID: CODE, 24200 0 28
-_getCANFrame: CODE, 23622 0 44
-_main: CODE, 18458 0 280
-_ldexp: CODE, 20768 0 164
-___fldiv: CODE, 20600 0 168
-_handle_sync: CODE, 21666 0 130
-_Read_b_eep: CODE, 24410 0 18
-___lwtofl: CODE, 23666 0 42
-___flneg: CODE, 23946 0 36
-_vscp_goActiveState: CODE, 24112 0 30
-_vscp_doOneSecondWork: CODE, 22242 0 84
-_vscp_getRegisterPagesUsed: CODE, 24544 0 2
-_doOneSecondWork: CODE, 6682 0 2034
-_sendVSCPFrame: CODE, 20242 0 182
-_vscp_sendEvent: CODE, 23576 0 46
-_vscp_getMDF_URL: CODE, 24280 0 24
-_eval_poly: CODE, 19480 0 192
-_init_app_eeprom: CODE, 10680 0 1904
-_floor: CODE, 19014 0 252
-_sendCANFrame: CODE, 22856 0 72
-_Write_b_eep: CODE, 23476 0 52
-_ConvertADC: CODE, 24536 0 4
-_vscp_check_pstorage: CODE, 23126 0 62
-_vscp_writeStdReg: CODE, 18738 0 276
-_WriteTimer0: CODE, 24428 0 18
-_vscp_writeAppReg: CODE, 2926 0 3756
-_vscp_handleProtocolEvent: CODE, 12584 0 1620
-__initialization: CODE, 22998 0 56
-__ECANPointBuffer: CODE, 21916 0 118
-_vscp_getFamilyType: CODE, 24484 0 10
-_vscp_getBufferSize: CODE, 24546 0 2
-_vscp_getSubzone: CODE, 24464 0 10
-_vscp_getMatrixInfo: CODE, 24254 0 26
-_vscp_handleDropNickname: CODE, 23528 0 48
-_vscp_handleSetNickname: CODE, 24082 0 30
-_frexp: CODE, 21400 0 134
-_vscp_handleProbeState: CODE, 19864 0 190
-_vscp_goBootloaderMode: CODE, 24016 0 34
-___flpack: CODE, 19672 0 192
-_exp: CODE, 15838 0 484
-_writeCoeffs2Ram: CODE, 20932 0 160
-___asfladd: CODE, 22710 0 74
-_vscp_readNicknamePermanent: CODE, 24504 0 10
-_vscp_sendHeartBeat: CODE, 23832 0 38
-_Celsius2Fahrenheit: CODE, 22034 0 116
-_ECANInitialize: CODE, 21250 0 150
-___fladd: CODE, 17468 0 352
-___asfldiv: CODE, 22636 0 74
-_OpenTimer0: CODE, 24142 0 30
-_interrupt_at_low_vector: CODE, 2072 0 674
-i1_WriteTimer0: CODE, 24446 0 18
-_OpenADC: CODE, 22150 0 92
-log@coeff: SMALLCONST, 2888 0 36
-_vscp_getMajorVersion: CODE, 24554 0 2
-_vscp_getMinorVersion: CODE, 24552 0 2
-_vscp_writeNicknamePermanent: CODE, 24328 0 22
-_vscp_newNodeOnline: CODE, 23708 0 42
-__CANIDToRegs: CODE, 17820 0 336
-_vscp_init: CODE, 22326 0 80
-___awtofl: CODE, 23366 0 58
-_init_app_ram: CODE, 22928 0 70
-___asflmul: CODE, 22560 0 76
-___wmul: CODE, 23308 0 58
-___altofl: CODE, 22784 0 72
-_vscp_getManufacturerId: CODE, 24350 0 20
-___lbmod: CODE, 23792 0 40
-_vscp_getSubMinorVersion: CODE, 24550 0 2
-_ECANSetOperationMode: CODE, 24304 0 24
-_ECANSendMessage: CODE, 16754 0 358
-_vscp_getGUID: CODE, 24390 0 20
-Total: 22404
\ No newline at end of file
+_vscp_getBootLoaderAlgorithm: CODE, 24732 0 2
+PL12: CODE, 14404 0 22
+PL50: CODE, 18394 0 20
+PL8: CODE, 14364 0 14
+___asflsub: CODE, 22542 0 78
+_vscp_getZone: CODE, 24658 0 10
+PL22: CODE, 14456 0 26
+PL60: CODE, 23704 0 16
+_vscp_getControlByte: CODE, 24406 0 28
+_log: CODE, 17834 0 312
+PL32: CODE, 19216 0 18
+PL70: CODE, 22130 0 14
+_init: CODE, 23384 0 60
+_vscp_setManufacturerId: CODE, 24322 0 28
+PL42: CODE, 14526 0 20
+PL80: CODE, 17128 0 12
+exp@coeff: SMALLCONST, 3872 0 40
+___aldiv: CODE, 19912 0 188
+PL14: CODE, 14426 0 16
+PL52: CODE, 18414 0 18
+PL90: CODE, 14626 0 8
+_ECANReceiveMessage: CODE, 15732 0 484
+_vscp_getEvent: CODE, 23814 0 44
+___flmul: CODE, 19516 0 176
+_vscp_handleHeartbeat: CODE, 24740 0 2
+_vscp_readRegister: CODE, 24508 0 22
+PL24: CODE, 19200 0 16
+PL62: CODE, 7668 0 16
+_vscp_setGUID: CODE, 24094 0 36
+_sendTempEvent: CODE, 22028 0 102
+PL34: CODE, 13072 0 20
+PL72: CODE, 13092 0 14
+__RegsToCANID: CODE, 18146 0 196
+_vscp_deviceURL: SMALLCONST, 3840 0 32
+_vscp_writeRegister: CODE, 24202 0 30
+PL44: CODE, 19234 0 20
+PL82: CODE, 20276 0 12
+_getVSCPFrame: CODE, 22260 0 116
+i1_ConvertADC: CODE, 24724 0 4
+_vscp_setControlByte: CODE, 24166 0 36
+_vscp_getUserID: CODE, 24572 0 20
+PL16: CODE, 19180 0 20
+PL54: CODE, 14566 0 18
+_setEventData: CODE, 20826 0 176
+PL26: CODE, 20448 0 24
+PL64: CODE, 19692 0 16
+_Celsius2Kelvin: CODE, 23618 0 52
+_Busy_eep: CODE, 24706 0 6
+PL36: CODE, 14506 0 20
+PL74: CODE, 14598 0 14
+_vscp_error: CODE, 24712 0 4
+_doWork: CODE, 14634 0 1080
+_getCalibrationValue: CODE, 23200 0 62
+_vscp_init_pstorage: CODE, 24716 0 4
+___fltol: CODE, 21336 0 158
+_vscp_restoreDefaults: CODE, 24698 0 8
+PL46: CODE, 14546 0 20
+PL84: CODE, 14612 0 8
+___flsub: CODE, 23324 0 60
+___flge: CODE, 22620 0 76
+PL18: CODE, 18342 0 14
+PL56: CODE, 15714 0 18
+_vscp_readStdReg: CODE, 16724 0 384
+_vscp_readAppReg: CODE, 7684 0 1954
+_vscp_getFamilyCode: CODE, 24678 0 10
+PL28: CODE, 14482 0 24
+PL66: CODE, 14584 0 14
+_vscp_setUserID: CODE, 24350 0 28
+_getCANFrame: CODE, 24020 0 38
+_main: CODE, 18432 0 280
+_ldexp: CODE, 21002 0 174
+___fldiv: CODE, 20650 0 176
+PL38: CODE, 18356 0 18
+PL76: CODE, 16216 0 14
+_handle_sync: CODE, 21772 0 130
+_Read_b_eep: CODE, 24460 0 24
+___lwtofl: CODE, 23858 0 42
+PL48: CODE, 17108 0 20
+PL86: CODE, 14620 0 6
+___flneg: CODE, 24058 0 36
+_vscp_goActiveState: CODE, 24262 0 30
+_vscp_doOneSecondWork: CODE, 22376 0 86
+_vscp_getRegisterPagesUsed: CODE, 24728 0 2
+PL58: CODE, 17816 0 18
+_doOneSecondWork: CODE, 13116 0 1176
+PL68: CODE, 19708 0 14
+_sendVSCPFrame: CODE, 20472 0 178
+_vscp_sendEvent: CODE, 23768 0 46
+_vscp_getMDF_URL: CODE, 24378 0 28
+_eval_poly: CODE, 20288 0 160
+PL78: CODE, 19254 0 10
+_init_app_eeprom: CODE, 9638 0 1904
+_floor: CODE, 19264 0 252
+PL88: CODE, 13106 0 10
+_sendCANFrame: CODE, 23066 0 72
+_Write_b_eep: CODE, 23502 0 58
+_ConvertADC: CODE, 24720 0 4
+_vscp_check_pstorage: CODE, 23444 0 58
+_vscp_writeStdReg: CODE, 18712 0 276
+_WriteTimer0: CODE, 24612 0 18
+_vscp_writeAppReg: CODE, 3950 0 3718
+_vscp_handleProtocolEvent: CODE, 11542 0 1506
+__initialization: CODE, 23138 0 56
+__ECANPointBuffer: CODE, 21902 0 126
+_vscp_getFamilyType: CODE, 24668 0 10
+_vscp_getBufferSize: CODE, 24730 0 2
+_vscp_getSubzone: CODE, 24648 0 10
+_vscp_getMatrixInfo: CODE, 24434 0 26
+_vscp_handleDropNickname: CODE, 23720 0 48
+_vscp_handleSetNickname: CODE, 24232 0 30
+_frexp: CODE, 21638 0 134
+_vscp_handleProbeState: CODE, 19722 0 190
+_vscp_goBootloaderMode: CODE, 24130 0 36
+___flpack: CODE, 20100 0 176
+_exp: CODE, 16230 0 494
+_writeCoeffs2Ram: CODE, 21176 0 160
+___asfladd: CODE, 22846 0 74
+_vscp_readNicknamePermanent: CODE, 24688 0 10
+_vscp_sendHeartBeat: CODE, 23982 0 38
+_Celsius2Fahrenheit: CODE, 22144 0 116
+_ECANInitialize: CODE, 21494 0 144
+___fladd: CODE, 17492 0 324
+___asfldiv: CODE, 22772 0 74
+_OpenTimer0: CODE, 24292 0 30
+_interrupt_at_low_vector: CODE, 24 0 674
+i1_WriteTimer0: CODE, 24630 0 18
+_OpenADC: CODE, 22920 0 74
+log@coeff: SMALLCONST, 3912 0 36
+_vscp_getMajorVersion: CODE, 24738 0 2
+_vscp_getMinorVersion: CODE, 24736 0 2
+_vscp_writeNicknamePermanent: CODE, 24530 0 22
+_vscp_newNodeOnline: CODE, 23900 0 42
+__CANIDToRegs: CODE, 18988 0 192
+_vscp_init: CODE, 22462 0 80
+___awtofl: CODE, 23560 0 58
+PL2: CODE, 14292 0 14
+_init_app_ram: CODE, 23262 0 62
+___asflmul: CODE, 22696 0 76
+___wmul: CODE, 23670 0 34
+___altofl: CODE, 22994 0 72
+PL10: CODE, 14378 0 26
+PL4: CODE, 14306 0 30
+_vscp_getManufacturerId: CODE, 24552 0 20
+___lbmod: CODE, 23942 0 40
+PL20: CODE, 14442 0 14
+_vscp_getSubMinorVersion: CODE, 24734 0 2
+_ECANSetOperationMode: CODE, 24484 0 24
+PL30: CODE, 13048 0 24
+PL6: CODE, 14336 0 28
+PL40: CODE, 18374 0 20
+_ECANSendMessage: CODE, 17140 0 352
+_vscp_getGUID: CODE, 24592 0 20
+Total: 21568
\ No newline at end of file
diff --git a/kelvin_ntc.X/nbproject/Makefile-genesis.properties b/kelvin_ntc.X/nbproject/Makefile-genesis.properties
index 9125325..0c092d0 100644
--- a/kelvin_ntc.X/nbproject/Makefile-genesis.properties
+++ b/kelvin_ntc.X/nbproject/Makefile-genesis.properties
@@ -1,5 +1,5 @@
#
-#Wed Mar 23 18:46:42 CET 2016
+#Tue Mar 29 10:57:40 CEST 2016
Debug_26K80.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=12edf07df11dc3b48011abb2bbd51a8e
Relocated_2580.languagetoolchain.version=1.21
Debug_2580.languagetoolchain.dir=/opt/microchip/xc8/v1.21/bin
@@ -9,7 +9,7 @@ Relocated_2580.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=1
Debug_26K80.languagetoolchain.dir=/opt/microchip/xc8/v1.21/bin
Debug_26K80.languagetoolchain.version=1.21
Debug_2580.languagetoolchain.version=1.21
-configurations-xml=ea24d4f486978e966a4e855707f1dab8
+configurations-xml=3b9334fb1e0a3e18fc4ce2c7c533620a
Relocated_26K80.languagetoolchain.version=1.21
Relocated_2580.languagetoolchain.dir=/opt/microchip/xc8/v1.21/bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=4b47e815d50912689a67d0b162f47a58
diff --git a/kelvin_ntc.X/nbproject/Makefile-impl.mk b/kelvin_ntc.X/nbproject/Makefile-impl.mk
index 3b41ad5..4979ddc 100644
--- a/kelvin_ntc.X/nbproject/Makefile-impl.mk
+++ b/kelvin_ntc.X/nbproject/Makefile-impl.mk
@@ -27,7 +27,7 @@ CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
PROJECTNAME=kelvin_ntc.X
# Active Configuration
-DEFAULTCONF=Relocated_2580
+DEFAULTCONF=Debug_26K80
CONF=${DEFAULTCONF}
# All Configurations
diff --git a/kelvin_ntc.X/nbproject/configurations.xml b/kelvin_ntc.X/nbproject/configurations.xml
index 713525c..e95a4c4 100644
--- a/kelvin_ntc.X/nbproject/configurations.xml
+++ b/kelvin_ntc.X/nbproject/configurations.xml
@@ -63,7 +63,7 @@
RealICEPlatformTool
XC8
1.21
- 3
+ 2
@@ -230,7 +230,7 @@
RealICEPlatformTool
XC8
1.21
- 3
+ 2
@@ -391,13 +391,13 @@
localhost
- PIC18LF26K80
+ PIC18F26K80
RealICEPlatformTool
XC8
1.21
- 3
+ 2
@@ -564,7 +564,7 @@
RealICEPlatformTool
XC8
1.21
- 3
+ 2
diff --git a/kelvin_ntc.X/nbproject/private/configurations.xml b/kelvin_ntc.X/nbproject/private/configurations.xml
index 98a60df..92a58d6 100644
--- a/kelvin_ntc.X/nbproject/private/configurations.xml
+++ b/kelvin_ntc.X/nbproject/private/configurations.xml
@@ -1,11 +1,11 @@
Makefile
- 0
+ 2
-
- C:\Program Files (x86)\Microchip\xc8\v1.21\bin
+ :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9004:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB REAL ICE tm (www.microchip.com):=<sn>JIT113110039:=<drv>x:=<xpt>b:=end
+ /opt/microchip/xc8/v1.21/bin
place holder 1
place holder 2
@@ -23,7 +23,7 @@
- C:\Program Files (x86)\Microchip\xc8\v1.21\bin
+ /opt/microchip/xc8/v1.21/bin
place holder 1
place holder 2
@@ -40,8 +40,8 @@
-
- C:\Program Files (x86)\Microchip\xc8\v1.21\bin
+ :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9004:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB REAL ICE tm (www.microchip.com):=<sn>JIT113110039:=<drv>x:=<xpt>b:=end
+ /opt/microchip/xc8/v1.21/bin
place holder 1
place holder 2
@@ -58,8 +58,8 @@
-
- C:\Program Files (x86)\Microchip\xc8\v1.21\bin
+ :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9004:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB REAL ICE tm (www.microchip.com):=<sn>JIT113110039:=<drv>x:=<xpt>b:=end
+ /opt/microchip/xc8/v1.21/bin
place holder 1
place holder 2
diff --git a/main.c b/main.c
index 0fc5879..44ace59 100644
--- a/main.c
+++ b/main.c
@@ -5,7 +5,7 @@
* Kelvin NTC10KA Module
* =====================
*
- * Copyright (C) 2015-2016 Ake Hedman, Grodans Paradis AB
+ * Copyright (C) 2000-2016 Ake Hedman, Grodans Paradis AB
* http://www.grodansparadis.com
*
*
@@ -131,13 +131,13 @@ const uint8_t vscp_deviceURL[] = "www.eurosource.se/ntc10KA_3.xml";
// Global Variable Declarations
int16_t current_temp[6]; // Current temperature
-uint8_t adc[NUMBER_OF_TEMP_SERIES * 12];// Current ADC values
-uint8_t adc_conversion_flags; // Bits to flag new adc values
-uint8_t adc_series_counter; // Series counter
+uint8_t adc[NUMBER_OF_TEMP_SERIES * 12]; // Current ADC values
+uint8_t adc_conversion_flags; // Bits to flag new ADC values
+uint8_t adc_series_counter; // Series counter
-volatile uint16_t sendTimer; // Timer for CAN send
-volatile uint32_t measurement_clock; // Clock for measurements
-volatile uint32_t timeout_clock; // Clock used for timeouts
+volatile uint16_t sendTimer; // Timer for CAN send
+volatile uint32_t measurement_clock; // Clock for measurements
+volatile uint32_t timeout_clock; // Clock used for timeouts
uint8_t seconds; // counter for seconds
@@ -210,9 +210,11 @@ void interrupt low_priority interrupt_at_low_vector( void )
switch (0x3C & ADCON0) {
case SELECT_ADC_TEMP0:
+
// Read conversion
adc[(12 * adc_series_counter) + 0] = ADRESH;
adc[(12 * adc_series_counter) + 1] = ADRESL;
+
// Start new conversion
ADCON0 = SELECT_ADC_TEMP1 + 1;
@@ -224,6 +226,7 @@ void interrupt low_priority interrupt_at_low_vector( void )
break;
case SELECT_ADC_TEMP1:
+
// Read conversion
adc[(12 * adc_series_counter) + 2] = ADRESH;
adc[(12 * adc_series_counter) + 3] = ADRESL;
@@ -239,6 +242,7 @@ void interrupt low_priority interrupt_at_low_vector( void )
break;
case SELECT_ADC_TEMP2:
+
// Read conversion
adc[(12 * adc_series_counter) + 4] = ADRESH;
adc[(12 * adc_series_counter) + 5] = ADRESL;
@@ -254,9 +258,11 @@ void interrupt low_priority interrupt_at_low_vector( void )
break;
case SELECT_ADC_TEMP3:
+
// Read conversion
adc[(12 * adc_series_counter) + 6] = ADRESH;
adc[(12 * adc_series_counter) + 7] = ADRESL;
+
// Start new conversion
ADCON0 = SELECT_ADC_TEMP4 + 1;
@@ -268,9 +274,11 @@ void interrupt low_priority interrupt_at_low_vector( void )
break;
case SELECT_ADC_TEMP4:
+
// Read conversion
adc[(12 * adc_series_counter) + 8] = ADRESH;
adc[(12 * adc_series_counter) + 9] = ADRESL;
+
// Start new conversion
ADCON0 = SELECT_ADC_TEMP5 + 1;
@@ -282,9 +290,11 @@ void interrupt low_priority interrupt_at_low_vector( void )
break;
case SELECT_ADC_TEMP5:
+
// Read conversion
adc[(12 * adc_series_counter) + 10] = ADRESH;
adc[(12 * adc_series_counter) + 11] = ADRESL;
+
// Start new conversion
ADCON0 = SELECT_ADC_TEMP0 + 1;
@@ -302,10 +312,12 @@ void interrupt low_priority interrupt_at_low_vector( void )
break;
default:
+
// Start new conversion
ADCON0 = SELECT_ADC_TEMP0 + 1;
adc_series_counter = 0;
break;
+
}
// Start conversion
@@ -478,7 +490,7 @@ void doWork(void)
// Calculate mean value for this adc
avarage = 0;
for (j = 0; j < NUMBER_OF_TEMP_SERIES; j++) {
- avarage += ((uint16_t)adc[12 * j + 2 * i])*256 + adc[12 * j + 2 * i + 1];
+ avarage += ( (uint16_t)adc[12 * j + 2 * i]<<8 ) + adc[12 * j + 2 * i + 1];
}
avarage = avarage / NUMBER_OF_TEMP_SERIES;
@@ -490,13 +502,17 @@ void doWork(void)
// R1 = (R2V - R2V2) / V2 R2= 10K, V = 5V, V2 = adc * voltage/1024
// T = B / ln(r/Rinf)
// Rinf = R0 e (-B/T0), R0=10K, T0 = 273.15 + 25 = 298.15
- B = (uint16_t)eeprom_read(2 * i + EEPROM_B_CONSTANT0_MSB)*256 +
+ B = (uint16_t)eeprom_read(2 * i + ( EEPROM_B_CONSTANT0_MSB)<<8 ) +
eeprom_read(2 * i + EEPROM_B_CONSTANT0_LSB);
Rinf = 10000.0 * exp(B / -298.15);
//itemp = Rinf * 10000;
+#if defined(_18F2580)
v = 5.0 * (double) avarage / 1025;
+#else
+ v = 5.0 * (double) avarage / 4097;
+#endif
//itemp = v * 100;
resistance = (calVoltage - 10000.0 * v) / v;
//itemp = r;
@@ -526,7 +542,12 @@ void doWork(void)
// ================
// Assuming a 10k Thermistor. Calculation is actually: Resistance = (1024/ADC)
+#if defined(_18F2580)
resistance = ((10240000 / adc[2 * i + 1]) - 10000);
+#else
+ // Assuming a 10k Thermistor. Calculation is actually: Resistance = (4096/ADC)
+ resistance = ((40960000 / adc[2 * i + 1]) - 10000);
+#endif
/********************************************************************/
/* Utilizes the Steinhart-Hart Thermistor Equation: */
@@ -918,8 +939,6 @@ int16_t getCalibrationValue(uint8_t i)
void init()
{
- //uint8_t msgdata[ 8 ];
-
// Initialize data
init_app_ram();
@@ -971,26 +990,24 @@ void init()
// Initialize CAN
ECANInitialize();
+/*
+ {
+ uint8_t msgdata[ 8 ];
+
// Must be in Config. mode to change many of settings.
//ECANSetOperationMode(ECAN_OP_MODE_CONFIG);
// Return to Normal mode to communicate.
//ECANSetOperationMode(ECAN_OP_MODE_NORMAL);
- /*
- msgdata[ 0 ] = 1;
- msgdata[ 1 ] = 2;
- msgdata[ 2 ] = 3;
- msgdata[ 3 ] = 4;
-
- if ( vscp18f_sendMsg( 0x123,
- * msgdata,
- * 4,
- * CAN_TX_PRIORITY_0 & CAN_TX_XTD_FRAME & CAN_TX_NO_RTR_FRAME ) ) {
- ;
- }
+ msgdata[ 0 ] = 1;
+ msgdata[ 1 ] = 2;
+ msgdata[ 2 ] = 3;
+ msgdata[ 3 ] = 4;
- */
+ sendCANFrame( 12345, 4, msgdata );
+ }
+*/
// Enable global interrupt
INTCONbits.GIE = 1;
@@ -1909,14 +1926,7 @@ uint8_t vscp_readAppReg(unsigned char reg)
}
// Raw A/D values
else if (reg < 84) {
- // The byte order is different in registers
uint8_t pos = reg - 72;
- if ( pos % 2 ) {
- pos--;
- }
- else {
- pos++;
- }
rv = adc[ pos ];
}
// Sensor calibration values
@@ -2570,16 +2580,9 @@ uint8_t vscp_writeAppReg(unsigned char reg, unsigned char val)
rv = eeprom_read(EEPROM_COEFFICIENT_A_SENSOR0_0 + reg );
writeCoeffs2Ram();
}
- // Raw A/D values is not writable
+ // Raw A/D values is NOT writable
else if (reg < 84) {
- // The byte order is different in registers
uint8_t pos = reg - 72;
- if ( pos % 2 ) {
- pos--;
- }
- else {
- pos++;
- }
rv = adc[ pos ];
}
// Sensor calibration values