C51 COMPILER V8.05a   MAIN                                                                 03/28/2008 10:31:50 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\ProgramFiles\Keil\C51\BIN\C51.EXE main.c OPTIMIZE(SIZE) BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*
   2          -------------------------------------------------------------------------------
   3          -- (c) Copyright 2006 Actel Corporation
   4          --
   5          -- name:                main.c
   6          -- function:    Simplified routines for CLosed Loop Trim Demo
   7          -- comments:    best viewed with tabstops set to "4"
   8          -- history:             2008/03/24 - SNG created
   9          --
  10          -------------------------------------------------------------------------------
  11          */
  12          #include "reg8051s.h"
  13          //#include <stdlib.h>
  14          //#include <stdio.h>
  15          //#include <math.h>
  16          
  17          #include "ClosedLoopDemomap.h"
  18          #include "COREUARTAPB.H"
  19          #include "CoreDAC_eval.h"
  20          
  21          // main routine
  22          
  23          void main (void)  {
  24   1              uint16 ctmp;
  25   1              uint16 DAC;
  26   1              uint16 SetPoint;
  27   1              uint16 CurrentVoltage;
  28   1      
  29   1              // initialize CoreUARTapb that communicates with PC
  30   1      //      UART2_CTRL1 = 0x09; // baud-rate set to 115.2Kbaud (18.431MHz clock)
  31   1              UART2_CTRL1 = 0x04; // baud-rate set to 115.2Kbaud (9.816MHz clock)
  32   1              UART2_CTRL2 = 0x01; // no parity, 8-bit data
  33   1      
  34   1              // Set the default output to 1.5V
  35   1              DAC = 0x0C00;
  36   1              SetPoint = 0x05DC;
  37   1      
  38   1              // Print Menu
  39   1              PrintMenu();
  40   1          tx_str("Currently set to 1.5V...");
  41   1              tx_char(0x0d);tx_char('\n');
  42   1      
  43   1              // Infinite loop
  44   1              while (1) {
  45   2                      // check if any characters have been received
  46   2                      ctmp = rx_char();
  47   2                      if (ctmp!=0xffff) {
  48   3                              switch(ctmp) {
  49   4                                      // Check for up or down
  50   4                                      case '=' :
  51   4                                              if (SetPoint == 0x0FFF)
  52   4                                                      {SetPoint = 0;}
  53   4                                              else 
  54   4                                                      {SetPoint = SetPoint + 1;}
  55   4                                              PrintValues(SetPoint,DAC);
C51 COMPILER V8.05a   MAIN                                                                 03/28/2008 10:31:50 PAGE 2   

  56   4                                              break;
  57   4                                      case '-' :
  58   4                                              if (SetPoint == 0)
  59   4                                                      {SetPoint = 0x0FFF;}
  60   4                                              else 
  61   4                                                      {SetPoint = SetPoint - 1;} 
  62   4                                              PrintValues(SetPoint,DAC);
  63   4                                              break;
  64   4                                      case '0' : SetPoint = 0x0000; PrintValues(SetPoint,DAC); break;
  65   4                                      case '1' : SetPoint = 0x0100; PrintValues(SetPoint,DAC); break;
  66   4                                      case '2' : SetPoint = 0x0200; PrintValues(SetPoint,DAC); break;     
  67   4                                      case '3' : SetPoint = 0x0300; PrintValues(SetPoint,DAC); break;
  68   4                                      case '4' : SetPoint = 0x0400; PrintValues(SetPoint,DAC); break;
  69   4                                      case '5' : SetPoint = 0x0500; PrintValues(SetPoint,DAC); break;
  70   4                                      case '6' : SetPoint = 0x0600; PrintValues(SetPoint,DAC); break;
  71   4                                      case '7' : SetPoint = 0x0700; PrintValues(SetPoint,DAC); break;
  72   4                                      case '8' : SetPoint = 0x0800; PrintValues(SetPoint,DAC); break;
  73   4                                      case '9' : SetPoint = 0x0900; PrintValues(SetPoint,DAC); break;
  74   4                                      case 'a' : SetPoint = 0x0a00; PrintValues(SetPoint,DAC); break;
  75   4                                      case 'b' : SetPoint = 0x0b00; PrintValues(SetPoint,DAC); break;
  76   4                                      case 'c' : SetPoint = 0x0c00; PrintValues(SetPoint,DAC); break;
  77   4                                      case 'd' : SetPoint = 0x0d00; PrintValues(SetPoint,DAC); break;
  78   4                                      case 'e' : SetPoint = 0x0e00; PrintValues(SetPoint,DAC); break;
  79   4                                      case 'f' : SetPoint = 0x0f00; PrintValues(SetPoint,DAC); break;
  80   4                                      case 'l' :
  81   4                                              PrintMean(DAC);
  82   4                                              PrintValues(SetPoint,DAC);
  83   4                                              break;
  84   4                                      case 'm' :
  85   4                                              PrintMenu();
  86   4                                              break;
  87   4                                      case '!' :      // <Shift>-1
  88   4                                              DAC = 0x0F00; // Only get it close and let the algo do the rest
  89   4                                              SetPoint = 0x0384;  // 0900 Decimal
  90   4                                              SetDAC(DAC);
  91   4                                              tx_char(0x0d);tx_char('\n');
  92   4                                      tx_str("Setting rail to 0.9V...");
  93   4                                              tx_char(0x0d);tx_char('\n');
  94   4                                              PrintValues(SetPoint,DAC);                                      
  95   4                                              break;
  96   4                                      case '@' :      // <Shift>-2
  97   4                                              DAC = 0x0E10; // Only get it close and let the algo do the rest
  98   4                                              SetPoint = 0x044C;  // 1100 Decimal
  99   4                                              SetDAC(DAC);
 100   4                                              tx_char(0x0d);tx_char('\n');
 101   4                                      tx_str("Setting rail to 1.1V...");
 102   4                                              tx_char(0x0d);tx_char('\n');
 103   4                                              PrintValues(SetPoint,DAC);      
 104   4                                              break;                          
 105   4                                      case '#' :  // <Shift>-3
 106   4                                              DAC = 0x0C00; // Only get it close and let the algo do the rest
 107   4                                              SetPoint = 0x05DC;  // 1500 Decimal
 108   4                                              SetDAC(DAC);
 109   4                                      tx_char(0x0d);tx_char('\n');
 110   4                                              tx_str("Setting rail to 1.5V...");
 111   4                                              tx_char(0x0d);tx_char('\n');
 112   4                                              PrintValues(SetPoint,DAC);
 113   4                                              break;
 114   4                                      case '$' :  // <Shift>-4 
 115   4                                              DAC = 0x0AC0; // Only get it close and let the algo do the rest
 116   4                                              SetPoint = 0x0708;  // 1800 Decimal
 117   4                                              SetDAC(DAC);
C51 COMPILER V8.05a   MAIN                                                                 03/28/2008 10:31:50 PAGE 3   

 118   4                                      tx_char(0x0d);tx_char('\n');
 119   4                                              tx_str("Setting rail to 1.8V...");
 120   4                                              tx_char(0x0d);tx_char('\n');
 121   4                                              PrintValues(SetPoint,DAC);
 122   4                                              break;
 123   4                                      case '%' :      // <Shift>-5
 124   4                                              DAC = 0x0700; // Only get it close and let the algo do the rest
 125   4                                              SetPoint = 0x09C4;  // 2500 Decimal
 126   4                                              SetDAC(DAC);
 127   4                                      tx_char(0x0d);tx_char('\n');
 128   4                                              tx_str("Setting rail to 2.5V...");
 129   4                                              tx_char(0x0d);tx_char('\n');
 130   4                                              PrintValues(SetPoint,DAC);
 131   4                                              break;
 132   4                                      case '^' :      // <Shift>-6
 133   4                                              DAC = 0x0300; // Only get it close and let the algo do the rest
 134   4                                              SetPoint = 0x0CE4;  // 3300 Decimal
 135   4                                              SetDAC(DAC);
 136   4                                      tx_char(0x0d);tx_char('\n');
 137   4                                              tx_str("Setting rail to 3.3V...");
 138   4                                              tx_char(0x0d);tx_char('\n');
 139   4                                              PrintValues(SetPoint,DAC);
 140   4                                              break;
 141   4                                      default : break;
 142   4                              }
 143   3                      }
 144   2                      // Need to set GPIO[15] and then clear GPIO[15] while maintaining
 145   2                      // GPIO[11:0] for the DAC update to occur
 146   2                      CurrentVoltage = get_avg_sample(DAC);
 147   2                      if (CurrentVoltage > SetPoint + 1)
 148   2                              DAC = DAC + 1;
 149   2                      if (CurrentVoltage < SetPoint -1) 
 150   2                              DAC = DAC - 1;
 151   2                      SetDAC(DAC);
 152   2              }
 153   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1289    ----
   CONSTANT SIZE    =    626    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      32
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
