Analogical Systems

Electronics Design & Management

Our Services

Communication Consultancy

Product Definition

Simulation

Schematic Capture

Printed Circuit Layout

Firmware

Assembly & Test

Documentation, Warranty & Support

News & Links

Contact Us!

 

Firmware Design & Debug

Even for quite simple products, the preferred implementation is often to use a microprocessor because of its extreme flexibility. Using a microprocessor means that changes in the design specification can often be accommodated quickly and cheaply. One of our previous designs has now been used for four separate and different purposes!

We have tools to write firmware in C, BASIC or Assembler for a variety of microprocessors. We also write software for Personal Computers, written in Visual Basic.

The code fragment shown is from a data logger, written in Keil "C" for a P89C51RC2 microprocessor.

 

Next:  Assembly & Test

 

 

 

 

 

if((Chickmsg.Bite[0] >= CID) && (Chickmsg.Bite[0] < (CID + 32))) {

    CIDOff = Chickmsg.Bite[0] - CID;                                               // Offset points into Counts[]

        CRxByte = (CIDOff>> 3) & 3;                                                 // Extract byte arrays index

        CRxBit = 1 << (CIDOff & 7);                                                   // CRxBit is a 1 in the correct position

        CType = Chickmsg.Bite[1] & 0x70;                                        // mask in Type nibble      

        c = Chickmsg.ulong & 0xFFFFF;                                           // mask in pulse data only

        switch (CType) {                                                                     // choose Chick variant

            case 0x10:                                                                          // Type 1, pulse data

                ChickRx.Bite[CRxByte] = ChickRx.Bite[CRxByte] | CRxBit;    // Add flag to ChickRx array

                 Bin2PBCD(c);                                                                // Convert pulse count from binary to PBCD

                 break;

             case 0x20:                                                                         // Type 2, analog

                  if((Chickmsg.Bite[0] & 7) == 4) {     // if the address computes to DBGET channel 5 (base 1)

                      ChickRx.Bite[CRxByte] = ChickRx.Bite[CRxByte] | CRxBit;   // Add flag to ChickRx array

                      c = c>>2;                                                                   // Move c down two places,

                       Bin2PBCD(c);                                                          // put into Counts[] in PBCD format        

                       ChickAn.Bite[CRxByte] = (unsigned char) c;          //and into Analog array

                       }

                   break;

             case 0x30:                                                                        // Type 3, Max Demand pulse data

                 if((Chickmsg.Bite[0] & 7) == 0) {           

                      // if the address computes to DBGET channel 0

                      ChickRx.Bite[CRxByte] = ChickRx.Bite[CRxByte] | CRxBit;   // Add flag to ChickRx array

                      MD.Bite[CRxByte] = MD.Bite[CRxByte] | CRxBit;   // And to MD array

                      if(!MDTime) {                                                            // If necessary, start 10 sec timer

                                MDTime=MDTimeMax;

                                }

                      Counts.ulong[CIDOff] = Bin2PBCD(c);                    // Convert pulse count from binary to PBCD

                      }

                break;