Index: /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
===================================================================
--- /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 34)
+++ /webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (revision 35)
@@ -5,6 +5,5 @@
// Pin I/O LED Control Maskbit
#define DIR_RS485 0x00080000 // P1.19(0000 0000 0000 x000 0000 0000 0000 0000)
-#define RXD_RS485() IOCLR1 = DIR_RS485 // RS485 Direction = 0 (Receive)
-#define TXD_RS485() IOSET1 = DIR_RS485 // RS485 Direction = 1 (Transmit)
+
#define RX_UART3_BUF_SIZE 100
@@ -38,4 +37,5 @@
const unsigned char init1_rsp[] = "\x02\xf0\xb0\x08\x00\x84\x09\x0c\x04\x0a\x26\x86\xcd\x00\x03"; /* exp. init seq response */
const unsigned char init1_r_m[] = "\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff"; /* exp. init seq response mask */
+/* init1_r_m: response after first init: \x02\xf0\xb0\x08 , later: \x02\xf0\xb0\x09 */
@@ -50,4 +50,5 @@
const unsigned char init_after_all_chan[] = "\x02\xb0\xf0\x04\x00\x21\x00\xcc\x35\x03"; // send to SC after all channels have been scanned
+// ^^ equals init1[]
const unsigned char init_after_all_chan_rsp[] = "\x02\xf0\xb0\x09\x00\xa1\xfd\x03\x00\x00\x00\x00\x07\x21\x03"; // response from SC to init_after_all_chan[]
@@ -89,4 +90,16 @@
+void RXD_RS485(void)
+{
+ IOCLR1 = DIR_RS485; // RS485 Direction = 0 (Receive)
+} /* RXD_RS485 */
+
+void TXD_RS485(void)
+{
+ delay(500000);
+ IOSET1 = DIR_RS485; // RS485 Direction = 1 (Transmit)
+} /* TXD_RS485 */
+
+
void testUART3(void)
@@ -256,4 +269,5 @@
{
case SOL_NO_INIT:
+ delay(500000);
init_serial3();
resetUart3RxBuf(); /* init */
@@ -261,4 +275,5 @@
TXD_RS485();
+ delay(500000);
/* send init 1 */
send_uart3((unsigned char *)init1, sizeof(init1));
@@ -317,6 +332,5 @@
break;
case 6:
- /* we are through with all the channels, send the final init */
- send_uart3((unsigned char *)init_after_all_chan, sizeof(init_after_all_chan));
+ /* we are through with all the channels, ready to send next init for next query round */
solarState = SOL_FINISHED;
break;
@@ -327,5 +341,5 @@
if (solarState != SOL_FINISHED)
{
- solarState = SOL_CHAN_WAIT_REPLY;
+ solarState = SOL_CHAN_WAIT_REPLY; /* wait for reply if not finished */
} /* if */
break;
@@ -373,13 +387,25 @@
{
chanVolt[currentChannel] = rxUART3[11];
- chanWatt[currentChannel] = (int)rxUART3[7] | (((int)(rxUART3[6])) << 8) /* index 7: LSB, index 6: MSB */;
+ chanWatt[currentChannel] = (int)(rxUART3[7]) | (((int)(rxUART3[8])) << 8) /* index 7: LSB, index 8: MSB */;
} /* if */
- /* finally, discard data from buffer */
- resetUart3RxBuf();
-
- /* switch to next channel */
- currentChannel++;
- /* now ready to query channel data for next channel */
- solarState = SOL_CHAN;
+
+ if (currentChannel != 6)
+ {
+ /* we received input from channel 0 to 5 */
+
+ /* finally, discard data from buffer */
+ resetUart3RxBuf();
+
+ /* switch to next channel */
+ currentChannel++;
+ /* now ready to query channel data for next channel */
+ solarState = SOL_CHAN;
+ }
+ else
+ {
+ /* we received the finishing sequence */
+ solarState = SOL_NO_INIT; /* restart the measurement cycle */
+ }
+
}
else
@@ -495,5 +521,7 @@
void delay(unsigned long int count1)
{
- while(count1 > 0) {count1--;} // Loop Decrease Counter
+ volatile unsigned long int countVol;
+ countVol = count1;
+ while(countVol > 0) {countVol--;} // Loop Decrease Counter
}
Index: /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs
===================================================================
--- /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (revision 34)
+++ /webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (revision 35)
@@ -3,5 +3,5 @@
-
+
@@ -42,8 +42,8 @@
-
+
+
-
-
+
@@ -58,20 +58,20 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+