summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SPI.c40
-rw-r--r--SPI.h5
-rw-r--r--build/default/debug/SPI.obin15520 -> 15548 bytes
-rw-r--r--build/default/debug/main.obin9436 -> 8156 bytes
-rw-r--r--build/default/debug/mcc_generated_files/mssp2_i2c.obin19200 -> 19196 bytes
-rw-r--r--build/default/production/SPI.obin15596 -> 15592 bytes
-rw-r--r--build/default/production/main.obin8384 -> 8560 bytes
-rw-r--r--dist/default/production/memoryfile.xml8
-rw-r--r--main.c49
-rw-r--r--nbproject/Makefile-genesis.properties6
-rw-r--r--nbproject/configurations.xml14
-rw-r--r--nbproject/private/SuppressibleMessageMemo.properties3
12 files changed, 45 insertions, 80 deletions
diff --git a/SPI.c b/SPI.c
index 1a1b8b6..a6590b4 100644
--- a/SPI.c
+++ b/SPI.c
@@ -31,7 +31,7 @@
if (Ohm_150 > 15) Ohm_150 = 15;
if (Ohm_68 > 5) Ohm_68 = 5;
//WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b000000;
- WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0b10000000;
+ WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x80;
//WriteBuffer[1] = 0xFF >> (15-Ohm_150);
//WriteBuffer[3] = 0xFE << (7-(Ohm_150-8)) | (Ohm_68 - 4);
//2WriteBuffer[1] = 0x0F << (4-(Ohm_68 - 1)) | (testLED << 7);
@@ -41,23 +41,28 @@
WriteBuffer[5] = 0xff >> (15-Ohm_150);
//WriteBuffer[1] = 0xFF;
//if (Ohm_68 == 5) WriteBuffer[3]|= 0b10000000;
+ SPI_slaveSelect();
readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer);
+ SPI_slaveDeselect();
}
- int active150()
+ void active(uint8_t *ohm150, uint8_t *ohm68)
{
WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x40;
WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x02;
+ SPI_slaveSelect();
readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer);
- return bitcount(ReadBuffer[2]&0x7F) + (bitcount(ReadBuffer[4])); //+ bitcount(ReadBuffer[3] << 1));
- }
- int active68()
- {
- WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x40;
- WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x02;
+ SPI_slaveDeselect();
+ WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x00;
+ WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x00;
+ SPI_slaveSelect();
readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer);
- return ((ReadBuffer[2] & 0x80) + bitcount(ReadBuffer[0] & 0x0f));
+ SPI_slaveDeselect();
+ ohm150 = bitcount(ReadBuffer[3]&0x7F) + bitcount(ReadBuffer[5]); //+ bitcount(ReadBuffer[3] << 1));
+ //ohm150 = bitcount(ReadBuffer[3]);// + ReadBuffer[5] + ReadBuffer[3] + ReadBuffer[1];
+ ohm68 = ((ReadBuffer[3] & 0x80)>>7) + bitcount(ReadBuffer[0] & 0x0f);
}
+
void Message_BIM(uint8_t outputs[3])
{
WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b000001;
@@ -114,16 +119,13 @@
WriteBuffer[5] = outputs[2];
}
- void Message_HWCR(uint8_t outputs[3])
- {
- //WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b001100;
- //WriteBuffer[1] = outputs[0];
- //WriteBuffer[3] = outputs[1];
- //WriteBuffer[5] = outputs[2];
-
- WriteBuffer[0] = 0b10001100;
- WriteBuffer[1] = 0b10000000;
- readData = MSSP1_SPI_Exchange8bitBuffer(*WriteBuffer, 2, *ReadBuffer);
+ void Message_HWCR()
+ {
+ WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x8C;
+ WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0xC0;
+ SPI_slaveSelect();
+ readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer);
+ SPI_slaveDeselect();
}
void Message_HWCROCL(uint8_t outputs[3])
diff --git a/SPI.h b/SPI.h
index 3988e80..4181835 100644
--- a/SPI.h
+++ b/SPI.h
@@ -57,8 +57,7 @@
Message_OUT(15, 5, false); //Max Load with testLED turned off.
*/
- int active150(void);
- int active68(void);
+ void active(uint8_t *ohm150, uint8_t *ohm68);
int bitcount(uint8_t);
void Message_BIM(uint8_t outputs[3]);
/**
@@ -275,7 +274,7 @@ bits (DIAG_OLONEN.MUX) (3:0)
Message_DAGOLONEN({0b00000000, 0xFF, 0xFF}); //Open Load ON active on channel 0 of the first IC.
*/
- void Message_HWCR(uint8_t outputs[3]);
+ void Message_HWCR(void);
/**
@Summary
Hardware Configuration Register Bits
diff --git a/build/default/debug/SPI.o b/build/default/debug/SPI.o
index 40daf0f..aad8f34 100644
--- a/build/default/debug/SPI.o
+++ b/build/default/debug/SPI.o
Binary files differ
diff --git a/build/default/debug/main.o b/build/default/debug/main.o
index 46253d4..2e756c0 100644
--- a/build/default/debug/main.o
+++ b/build/default/debug/main.o
Binary files differ
diff --git a/build/default/debug/mcc_generated_files/mssp2_i2c.o b/build/default/debug/mcc_generated_files/mssp2_i2c.o
index 3837607..4a618a4 100644
--- a/build/default/debug/mcc_generated_files/mssp2_i2c.o
+++ b/build/default/debug/mcc_generated_files/mssp2_i2c.o
Binary files differ
diff --git a/build/default/production/SPI.o b/build/default/production/SPI.o
index 528ca5c..a1791f2 100644
--- a/build/default/production/SPI.o
+++ b/build/default/production/SPI.o
Binary files differ
diff --git a/build/default/production/main.o b/build/default/production/main.o
index 8414092..189c9dc 100644
--- a/build/default/production/main.o
+++ b/build/default/production/main.o
Binary files differ
diff --git a/dist/default/production/memoryfile.xml b/dist/default/production/memoryfile.xml
index 6dda4a3..d64cd8d 100644
--- a/dist/default/production/memoryfile.xml
+++ b/dist/default/production/memoryfile.xml
@@ -5,14 +5,14 @@
<memory name="data">
<units>bytes</units>
<length>2048</length>
- <used>96</used>
- <free>1952</free>
+ <used>100</used>
+ <free>1948</free>
</memory>
<memory name="program">
<units>bytes</units>
<length>16128</length>
- <used>4161</used>
- <free>11967</free>
+ <used>4188</used>
+ <free>11940</free>
</memory>
</executable>
</project>
diff --git a/main.c b/main.c
index e99c874..77d9b11 100644
--- a/main.c
+++ b/main.c
@@ -53,7 +53,6 @@
/*
Main application
*/
-uint8_t nullarray = {0x00, 0x00, 0x00};
uint8_t desired150, desired68, current150, current68 = 0;
bool relay_delay = false;
@@ -68,9 +67,7 @@ int main(void)
_LATA0 = _LATA1 = 0;//_LATA4 = 1; //Activate gate driver chips
_LATA4 = 1;
- SPI_slaveSelect();
- Message_HWCR(nullarray);
- SPI_slaveDeselect();
+ Message_HWCR();
_LATB6 = 0;
_LATB7 = 1;
@@ -78,9 +75,6 @@ int main(void)
TMR1_SetInterruptHandler(&TMR1_Process);
- //MSSP2_I2C_ReadPointerSet(0b00000011);
- // MSSP2_I2C_WritePointerSet(0x00);
-
while (1)
{
desired150 = getI2CArray(1) & 0x0F;
@@ -89,68 +83,35 @@ int main(void)
//if((relay_delay)&&(getTimeoutCounter() < 2))
//{
//relay_delay = false;
- SPI_slaveSelect();
- current150 = current150();
- SPI_slaveDeselect();
- /*
- SPI_slaveSelect();
- current68 = active68();
- SPI_slaveDeselect();
-
+ active(&current150,&current68);
+ /*
if(desired150 < current150)
{
- SPI_slaveSelect();
Message_OUT(current150-1, current68, 1);
- SPI_slaveDeselect();
}
else if(desired150 > current150)
{
- SPI_slaveSelect();
Message_OUT(current150+1, current68, 1);
- SPI_slaveDeselect();
}
else if(desired68 < current68)
{
- SPI_slaveSelect();
Message_OUT(current150, current68-1, 1);
- SPI_slaveDeselect();
}
else if(desired68 > current68)
{
- SPI_slaveSelect();
Message_OUT(current150, current68+1, 1);
- SPI_slaveDeselect();
}
}
if(getTimeoutCounter() > 2){ //Open contactors if I2C communication is broken.
- SPI_slaveSelect();
Message_OUT(0, 0, 0);
- SPI_slaveDeselect();
_LATB8 = 0;
_LATB7 = 1;
}*/
+ Message_OUT(2, 0, relay_delay);
- SPI_slaveSelect();
- Message_OUT(desired150, 0, relay_delay);
- SPI_slaveDeselect();
- /*
- SPI_slaveSelect();
- Message_OUT(15, 5, 0);
- SPI_slaveDeselect();
-
- SPI_slaveSelect();
- Message_OUT(15, 5, 0);
- SPI_slaveDeselect();
- *
- *
-*/
- //SPI_slaveSelect();
- //Message_OUT(15, i2cArray[1] >> 4, 0);
- //SPI_slaveDeselect();
- //if(MSSP2_I2C_WritePointerGet() > 50) {_LATB7 = 0; _LATB6 = 1;}
- //else {_LATB6 = 0; _LATB7 = 1;}
+ if(current150>0){_LATB8=0; _LATB7=0;}
}
return 1;
diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties
index e7e8590..58a5b7d 100644
--- a/nbproject/Makefile-genesis.properties
+++ b/nbproject/Makefile-genesis.properties
@@ -1,11 +1,11 @@
#
-#Fri Apr 26 12:52:12 CDT 2024
+#Thu May 02 18:31:10 CDT 2024
default.languagetoolchain.version=2.10
default.Pack.dfplocation=/opt/microchip/mplabx/v6.15/packs/Microchip/PIC24F-KA-KL-KM_DFP/1.4.83
conf.ids=default
default.languagetoolchain.dir=/opt/microchip/xc16/v2.10/bin
-host.id=0
-configurations-xml=67675cd84f9b3787f20789de6c2794fb
+host.id=17y8-g9hi-6g
+configurations-xml=548bce5bcce17c7b8a52ea2b767e1662
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=e62346c0c0ecee2637e613b49cb7b7fa
proj.dir=/home/josh/MPLABXProjects/resbox
default.com-microchip-mplab-mdbcore-pk4hybrid-Pk4HybridTooImpl.md5=38058ec39ea8224adcc766836376f0d6
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
index e4b4ca8..8b11231 100644
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -731,7 +731,8 @@
<property key="codecoverage.enableoutputtofile" value="false"/>
<property key="codecoverage.outputfile" value=""/>
<property key="communication.activationmode" value="nohv"/>
- <property key="communication.interface" value=""/>
+ <property key="communication.interface"
+ value="${communication.interface.default}"/>
<property key="communication.interface.jtag" value="2wire"/>
<property key="communication.speed" value="${communication.speed.default}"/>
<property key="debugoptions.debug-startup" value="Use system settings"/>
@@ -776,7 +777,7 @@
<property key="poweroptions.powerenable" value="false"/>
<property key="programmerToGoFilePath"
value="/home/josh/MPLABXProjects/resbox.X/debug/default/resbox_ptg"/>
- <property key="programmerToGoImageName" value="resbox_ptg"/>
+ <property key="programmerToGoImageName" value="default_ptg"/>
<property key="programoptions.donoteraseauxmem" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.ledbrightness" value="5"/>
@@ -785,7 +786,7 @@
<property key="programoptions.pgdconfig" value="pull down"/>
<property key="programoptions.pgdresistor.value" value="4.7"/>
<property key="programoptions.pgmentry.voltage" value="high"/>
- <property key="programoptions.pgmspeed" value="Med"/>
+ <property key="programoptions.pgmspeed" value="Min"/>
<property key="programoptions.preservedataflash" value="false"/>
<property key="programoptions.preservedataflash.ranges"
value="${memories.dataflash.default}"/>
@@ -1280,7 +1281,8 @@
<property key="UART 2" value="true"/>
<property key="ULPWU" value="true"/>
<property key="communication.activationmode" value="nohv"/>
- <property key="communication.interface" value=""/>
+ <property key="communication.interface"
+ value="${communication.interface.default}"/>
<property key="communication.interface.jtag" value="2wire"/>
<property key="communication.speed" value="${communication.speed.default}"/>
<property key="debugoptions.debug-startup" value="Use system settings"/>
@@ -1305,7 +1307,7 @@
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.ranges" value="0-2bff"/>
<property key="poweroptions.powerenable" value="false"/>
- <property key="programmerToGoImageName" value="resbox_ptg"/>
+ <property key="programmerToGoImageName" value="default_ptg"/>
<property key="programoptions.donoteraseauxmem" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.ledbrightness" value="5"/>
@@ -1314,7 +1316,7 @@
<property key="programoptions.pgdconfig" value="pull down"/>
<property key="programoptions.pgdresistor.value" value="4.7"/>
<property key="programoptions.pgmentry.voltage" value="high"/>
- <property key="programoptions.pgmspeed" value="Med"/>
+ <property key="programoptions.pgmspeed" value="Min"/>
<property key="programoptions.preservedataflash" value="false"/>
<property key="programoptions.preservedataflash.ranges"
value="${memories.dataflash.default}"/>
diff --git a/nbproject/private/SuppressibleMessageMemo.properties b/nbproject/private/SuppressibleMessageMemo.properties
index 3704710..7d0da5c 100644
--- a/nbproject/private/SuppressibleMessageMemo.properties
+++ b/nbproject/private/SuppressibleMessageMemo.properties
@@ -1,3 +1,4 @@
#
-#Wed Jan 31 16:17:43 CST 2024
+#Thu May 02 16:14:15 CDT 2024
PICkit\ 4/CHECK_4_HIGH_VOLTAGE_VPP=true
+PICkit\ 4/DEVID_MISMATCH=true