Show
Ignore:
Timestamp:
10/23/10 12:36:15 (14 years ago)
Author:
phil
Message:

- switched baud rate to 2400 (try to minimize errors)
- corrected binary coded hex number conversion algorithm for yield calculation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c

    r71 r72  
    929929{ 
    930930 
    931   unsigned int baud = 57600; 
     931  unsigned int baud = 2400; 
    932932  unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud); 
    933933 
     
    12031203                                    ) 
    12041204{ 
     1205  unsigned char currentChar; 
     1206  unsigned char conversionError = 0; 
    12051207 
    12061208  unsigned char x; 
    12071209  int resultValue = 0; /* initial value */ 
    12081210  unsigned char round = 0; /* which digit? 0 = LSB */ 
    1209   unsigned char currentCharValue; 
     1211  int currentCharValue; 
    12101212 
    12111213  /* go through the bytes backwards (least significant to most significant) */ 
    12121214  for (x = lastSrcByte; x >= firstSrcByte; x--) 
    12131215  { 
    1214  
    1215     currentCharValue = (srcDataStart[x]) - 0x30; 
     1216    currentChar = srcDataStart[x]; 
     1217    if ((currentChar < 0x30) || (currentChar > 0x46)) 
     1218    { 
     1219      conversionError = 1; 
     1220    } 
     1221    else if (currentChar <= 0x39) 
     1222    { 
     1223      // 0x0 to 0x9 
     1224      currentCharValue = (srcDataStart[x]) - 0x30; 
     1225    } 
     1226    else 
     1227    { 
     1228      // 0xA to 0xF 
     1229      currentCharValue = 0xA + ((srcDataStart[x]) - 0x41); 
     1230    } 
    12161231    resultValue = resultValue + (currentCharValue << (4 * round)); 
    12171232 
    12181233    round++; 
    12191234  } /* for */ 
     1235 
     1236  /* if a conversion error occurred, nullify the result */ 
     1237  if (conversionError == 1) 
     1238  { 
     1239      resultValue = 0xFFFF; 
     1240  } 
    12201241 
    12211242  return resultValue; 
  • webserver/example/EnergyMeters/Source/serial.c

    r37 r72  
    224224 
    225225 
    226   unsigned int baud = 57600; 
     226  unsigned int baud = 2400; 
    227227  unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud); 
    228228