Default binary file for sensor starter kit

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Default binary file for sensor starter kit

Jump to solution
2,696 Views
chethankumar
Contributor III

Hi

i am working with freescale sensor starter kit which contains accelerometer, pressure sensor and touch sensor. When i connected to computer through USB it was working fine i.e it got detected and GUI opened and worked on that. Now i dumped MMA8451 accelerometer code which i got in freescale s site

( AN4076SW). But now my device not getting detected. It showing erroe as "Please plug in hw". Now i want to  dump the default binary file for which it was working before. I searched in freesacles site but i didnt get any bainry file for that, and i didnt get any CD while purchasing that kit. So please can anyone help me to find binary file for that..

Thanks and Regards

CK

Labels (1)
1 Solution
1,826 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Chethan,

If you overwrote the original firmware on the MC9S08QE8 MCU bridge, the board is no longer recognized by Sensor Toolbox PC Software (STB GUI) because the bootloader section was removed by the AN4076SW.

You have to load e.g. the MMA8450Bootloader.s19 file (from C:\Program Files\Freescale\Sensor Toolbox\Bootloaders) into the MC9S08QE8, then power cycle the board, press the green button (Start or F5) and run the STB GUI. Then the STB GUI will take advantage of the bootloader to upload appropriate bridge firmware code.


In the attached file you will find instructions how to program the MC9S08QE8 MCU with the MMA8450Bootloader.s19 file.


Regards,

Tomas

View solution in original post

7 Replies
1,827 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Chethan,

If you overwrote the original firmware on the MC9S08QE8 MCU bridge, the board is no longer recognized by Sensor Toolbox PC Software (STB GUI) because the bootloader section was removed by the AN4076SW.

You have to load e.g. the MMA8450Bootloader.s19 file (from C:\Program Files\Freescale\Sensor Toolbox\Bootloaders) into the MC9S08QE8, then power cycle the board, press the green button (Start or F5) and run the STB GUI. Then the STB GUI will take advantage of the bootloader to upload appropriate bridge firmware code.


In the attached file you will find instructions how to program the MC9S08QE8 MCU with the MMA8450Bootloader.s19 file.


Regards,

Tomas

1,826 Views
chethankumar
Contributor III

Hi Tomas

i am working with freescale sensor starter kit LFSTBEB845X which contains MC9S08QE8CWL controller. I connected to PC through USB and my device is not getting detected. It showing error as "Please plug in hw". So now i dumped the default binary file which you provided to me and followed the same steps as mentioned in the attached PDF. When i load the .s19 file to the board i am getting error.. Error is " Could not erase the file.. Flashing failed.. What might be the issue?.. Its too urgent for me.. Hope you will help.

Thanks and Regards,

Chethan

0 Kudos
Reply
1,826 Views
chethankumar
Contributor III

Hi Tomas,

Sorry for the late reply. I followed those steps given in document. But nothing gets displayed on hyperterminal. And I2c lines are also blank whrn i observed it through logic analyser. I am using same commands which has been given in MMA8451Q document to read WHO_AM_I register and other registers.

And while debugging,  a window called True-Time Simulator & Real-Time Debugger will appear. My question is in source window is it necessary that main.c file only should appear? Because in my case Start08.c file is appeared? Is there anything we need to change?

Thanks and regards

Chethan

Here is my code:

In this SlaveAddressIIC = MMA845x_IIC_ADDRESS = 0x1C

#include <hidef.h> /* for EnableInterrupts macro */

#include "derivative.h" /* include peripheral declarations */

#include "system.h"

extern void _Startup(void);             // External startup function declared in file Start08.c

void MCU_Init(void); 

/***********************************************************************************************\

* Private memory declarations

\***********************************************************************************************/

/***********************************************************************************************\

* Public memory declarations

\***********************************************************************************************/

#pragma DATA_SEG __SHORT_SEG _DATA_ZEROPAGE

BIT_FIELD SystemFlag;                       // system control flags

extern BIT_FIELD StreamMode;                // stream mode control flags

byte SlaveAddressIIC;                       // accelerometer slave I2C address

byte functional_block;                      // accelerometer function

byte value[6];                              // working value result scratchpad

BIT_FIELD RegisterFlag;                     // temporary accelerometer register variable

byte full_scale;                            // current accelerometer full scale setting

int deviceID;

byte address_in[3];                         // Data Flash input address pointer

byte address_out[3];                        // Data Flash output address pointer

#pragma DATA_SEG DEFAULT

tfifo_sample fifo_data[FIFO_BUFFER_SIZE];   // FIFO sample buffer

/***********************************************************************************************\

* Public functions

\***********************************************************************************************/

#pragma MESSAGE DISABLE C1420 /* Warning C1420: Result of function-call is ignored */

/*********************************************************\

* Main Control Loop

\*********************************************************/

void main(void)

{

SCISendString ("started pgmng ");

  MCU_Init();

  /*

  **  Initialize system variables.

  */

  SystemFlag.Byte = 0;

  SCIControlInit();

  /*

  **  Wait for user input before proceeding.

  */

  SCI_CharIn();

  SCI_INPUT_READY = 0;

  EnableInterrupts;

  /*

  **  Initiate terminal interface.

  */

  TerminalInit();

  /*

  **  Verify IIC communications with the accelerometer

  */

  SlaveAddressIIC = MMA845x_IIC_ADDRESS;

  if (SA0_PIN == 1)

  {

    SlaveAddressIIC += 2;

  }

  /*

  **  Brute force delay for about 5ms

  */

  for (value[0]=0x10; value[0]!=0; value[0]--)

  {

    for (value[1]=0xFF; value[1]!=0; value[1]--) {}

  }

  /*

  **  Identify the accelerometer

  */

  

  value[0] = IIC_RegRead(SlaveAddressIIC, WHO_AM_I_REG);

  if (value[0] == MMA8451Q_ID)

  {

  SCISendString ("MMA8451Q: ");

  deviceID=1;

  OSMode_Normal=TRUE;

  }

  else if (value[0] == MMA8452Q_ID)

  {

  SCISendString ("MMA8452Q: ");

  deviceID=2;

  } 

  else if (value[0] == MMA8453Q_ID) 

  {

  SCISendString ("MMA8453Q: ");

    deviceID=3;

  }

    

  else

  {

    SCISendString ("not identified");

    

    for(;;) {};

  }

  /*

  **  MMA845x recognized

  **  Initialize it for 2g operation with an ODR of 200Hz.

  */

  MMA845x_Init();

  MMA845x_Active();

  full_scale= FULL_SCALE_2G;

  /*

  **  Output current status of the accelerometer

  */

  Print_ODR_HP();

  SCI_putCRLF();

  /**********************************************************************************************

  **  Enter the main control loop.

  */

  for(;;)

  {

    __RESET_WATCHDOG();

    /*

    **  Go process terminal input

    */

    ProcessTerminal();

    /*

    **  Determine if any sensor registers need to be polled

    */

    if (POLL_ACTIVE == TRUE)

    {

      switch (functional_block)

      {

        /////////////////////////////////////////////////////////////////////////////////////////

        case FBID_FULL_XYZ_SAMPLE:

          /*

          **  FULL XYZ Sample Registers 0x01-0x06 (MMA8451Q=14 bit, MMA8452Q= 12 bit, MMA8453Q= 10 bit

          **

          **  Poll ZYXDR bit in Status Register

          */

          

          RegisterFlag.Byte = IIC_RegRead(SlaveAddressIIC, STATUS_00_REG);

          if (RegisterFlag.ZYXDR_BIT == 1)

          {

            /*

            **  Read the  XYZ sample data

            */

            if (deviceID>3)

            

            {

              IIC_RegReadN(SlaveAddressIIC, OUT_X_MSB_REG, 3, &value[0]);

              

              

 

            } 

            else 

            {

              IIC_RegReadN(SlaveAddressIIC, OUT_X_MSB_REG, 6, &value[0]);

            }

            /*

            **  Output results

            */

            OutputTerminal (FBID_FULL_XYZ_SAMPLE, &value[0]);

          }

          break;

        

        /////////////////////////////////////////////////////////////////////////////////////////

        case FBID_FIFO:

          /*

          **  FIFO

          **

          **  Read the FIFO Status Register (0x00) and then read the 12-bit FIFO Data (0x12)

          */

          RegisterFlag.Byte = IIC_RegRead(SlaveAddressIIC, F_STATUS_REG);

          /*

          **  Go read FIFO with a single multi-byte IIC access

          */

          value[4] = (RegisterFlag.Byte & F_CNT_MASK) * 6;

          IIC_RegReadN(SlaveAddressIIC, OUT_X_MSB_REG, value[4], &fifo_data[0].Sample.XYZ.x_msb);

          OutputTerminal (FBID_FIFO, &fifo_data[0].Sample.XYZ.x_msb);

          break;

        /////////////////////////////////////////////////////////////////////////////////////////

        default:

          break;

      }

      if ((INT_STREAM == TRUE))

      {

        POLL_ACTIVE = FALSE;

      }

    }

  }

}

/*********************************************************\

* Power-on Reset Entry Point

\*********************************************************/

#pragma NO_FRAME

#pragma NO_EXIT

void _EntryPoint(void)

//void MCU_Init(void)

{

  /*

  **  Initialize General System Control

  */

  SOPT1 = init_SOPT1;                   // System Options Register 1

  SOPT2 = init_SOPT2;                   // System Options Register 2

  SPMSC1 = init_SPMSC1;                 // System Power Management Status and Control 1 Register

  SPMSC2 = init_SPMSC2;                 // System Power Management Status and Control 2 Register

  SPMSC3 = init_SPMSC3;                 // System Power Manag

SCGC1 = init_SCGC1;               // System Clock Gating Control 1 Register
  SCGC2 = init_SCGC2;               // System Clock Gating Control 2 Register

  /*

  **  Initialize Internal Clock Source

  */

  ICSTRM = NVICSTRM;                // ICS Trim Register
  ICSSC = NVICSTRM;                 // ICS Fine Trim
  ICSC1 = init_ICSC1;               // ICS Control Register 1
  ICSC2 = init_ICSC2;               // ICS Control Register 2

  while(!ICSSC_IREFST) {}           // Wait until source of reference clock is internal clock
  ICSSC = init_ICSSC;               // ICS Status and Control
  while((ICSSC & 0xC0) != 0x00) {}  // Wait until the FLL switches to Low range DCO mode

  /*

  **  Initialize Port I/O

  */

  PTAD = init_PTAD;                 // Port A Data Register
  PTAPE = init_PTAPE;               // Port A Pull Enable Register
  PTASE = init_PTASE;               // Port A Slew Rate Enable Register
  PTADS = init_PTADS;               // Port A Drive Strength Selection Register
  PTADD = init_PTADD;               // Port A Data Direction Register
  PTBD = init_PTBD;                 // Port B Data Register
  PTBPE = init_PTBPE;               // Port B Pull Enable Register
  PTBSE = init_PTBSE;               // Port B Slew Rate Enable Register
  PTBDS = init_PTBDS;               // Port B Drive Strength Selection Register
  PTBDD = init_PTBDD;               // Port B Data Direction Register
  PTCD = init_PTCD;                 // Port C Data Register
  PTCPE = init_PTCPE;               // Port C Pull Enable Register
  PTCSE = init_PTCSE;               // Port C Slew Rate Enable Register
  PTCDS = init_PTCDS;               // Port C Drive Strength Selection Register
  PTCDD = init_PTCDD;               // Port C Data Direction Register
  PTDD = init_PTDD;                 // Port D Data Register
  PTDPE = init_PTDPE;               // Port D Pull Enable Register
  PTDSE = init_PTDSE;               // Port D Slew Rate Enable Register
  PTDDS = init_PTDDS;               // Port D Drive Strength Selection Register
  PTDDD = init_PTDDD;               // Port D Data Direction Register

  /*

  **  Initialize Interrupt Pins (IRQ and KBI)

  */

  IRQSC = init_IRQSC;               // Interrupt Pin Request Status and Control Register
  KBISC = init_KBISC;               // KBI Interrupt Status and Control Register
  KBIPE = init_KBIPE;               // KBI Interrupt Pin Select Register
  KBIES = init_KBIES;               // KBI Interrupt Edge Select Register

  /*

  **  Initialize Inter-Integrated Circuit (IIC)

  */

  IICF = init_IICF;                 // IIC Frequency Divider Register
  IICC1 = init_IICC1;               // IIC Control Register 1

  /*

  **  Initialize Serial Communications Interface (SCI)

  */

  SCIBDH = init_SCIBDH;             // SCI Baud Rate Register High
  SCIBDL = init_SCIBDL;             // SCI Baud Rate Register Low
  SCIC1 = init_SCIC1;               // SCI Control Register 1
  SCIC2 = init_SCIC2;               // SCI Control Register 2
  SCIC3 = init_SCIC3;               // SCI Control Register 3

  /*

  **  Initialize Serial Peripheral Interface (SPI)

  */

  SPIBR = init_SPIBR;               // SPI Baud Rate Register
  SPIC2 = init_SPIC2;               // SPI Control Register 2
  SPIC1 = init_SPIC1;               // SPI Control Register 1

  /*

  **  Perform ANSI startup and jump into main control

  */

  __asm   jmp _Startup;             // Jump to C startup code

}

/*********************************************************\

**  Activate sensor interrupts

\*********************************************************/

void InterruptsActive (byte ctrl_reg3, byte ctrl_reg4, byte ctrl_reg5)

{

  MMA845x_Standby();

  IIC_RegWrite(SlaveAddressIIC, CTRL_REG3, (IIC_RegRead(SlaveAddressIIC, CTRL_REG3) | ctrl_reg3));

  IIC_RegWrite(SlaveAddressIIC, CTRL_REG4, ctrl_reg4);

  IIC_RegWrite(SlaveAddressIIC, CTRL_REG5, ctrl_reg5);

  MMA845x_Active();

  /*

  **  Enable keyboard interrupts

  */

  CLEAR_KBI_INTERRUPT;

  INT_PINS_ENABLED;

}

/*********************************************************\

* Keyboard Interrupt Service Routine

\*********************************************************/

interrupt void isr_KBI (void)

{

  /*

  **  Clear the interrupt flag

  */

  CLEAR_KBI_INTERRUPT;

  /*

  **  Go read the Interrupt Source Register

  */

  RegisterFlag.Byte = IIC_RegRead(SlaveAddressIIC, INT_SOURCE_REG);

  if (RegisterFlag.SRC_DRDY_BIT == 1)

  {

/*
**  Enable polling of the data - once.
*/
POLL_ACTIVE = TRUE;

  }

  if (RegisterFlag.SRC_FIFO_BIT == 1)

  {

POLL_ACTIVE = TRUE;

  }

}

/*********************************************************\

* Dummy Interrupt Service Routine

\*********************************************************/

interrupt void DummyIRQ (void)

{

}

// FUNCTION BODIES ////////////////////////////////////////////////////               
//---------------------------------------------------------------------               

void MCU_Init(void) 

{

// Crucial       
_asm SEI;                                // disable interrupts
SOPT1=0x23;                              // disable COP, enable Stop mode; Reset & Bkgd = BDM
SPMSC1=0x00;                             // disable LVDSE
SPMSC2=0x03;                             // enable Stop2 Mode

// System Clock Init

ICSTRM=NVICSTRM;                         // initialize ICSTRM register from NV_ICSTRM
ICSSC =NVFTRIM;                          // initialize ICSSC  register from NV_FTRIM

ICSC1=0x04;

ICSC2=0x00;                              // go to full bus speed (/1) instead of /2
ICSSC|=0x80;                             // Trim*512=32768Hz*512=16.777MHz (8.388MHz bus)

// ADC Init

ADCCFG=0x40;                             // 8 bits & 2.09MHz clock (/4)

// Timer1 Init

TPM2SC=0x08;                             // busclk/1=119ns per count
TPM2MOD=839-1;                           // 839 * 119ns = 100us period

// Timer2 Init (Buzzer)

TPM1SC=0x00;                             // busclk/1=119ns per count; buzzer on=0x08, off=0x00
TPM1C1SC=0x28;                           // edge-aligned PWM
TPM1MOD=19065-1;                         // 440Hz by default
TPM1C1V=19065>>1;                        // half of the above to produce 50% duty cycle PWM

// GPIO Init

PTAD=0x00;                               // LEDR (PTA0)                              
PTBD=0x00;                               // LEDG (PTB3) and LEDB (PTB4) are off by default
PTADD=0x01;                              // LEDR (PTA0) 
PTBDD=0x18;                              // LEDG (PTB3) and LEDB (PTB4) are outputs
PTBPE=0x04;                              // enable pull-ups for nSW4 (PTB2)

}

//---------------------------------------------------------------------

/***********************************************************************************************\

* Private functions

\***********************************************************************************************/

#pragma CODE_SEG REVISION

const byte Vendor[] @0xFFC0 = "Freescale";

0 Kudos
Reply
1,826 Views
chethankumar
Contributor III

Hi Tomas,

I found the solution for second question... I changed source file...

Thanks and regards

Chethan

0 Kudos
Reply
1,826 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Chethan,

First, sorry for the late response, but I have been out of the office the last couple of days.


Did you follow precisely the instructions given in the attached file?

Again: You need to run hiwave.exe program to flash the .s19 file and make sure to select the 9S08QE8 device and 36kHz custom trim frequency. It is key to select proper device and trim its reference frequency as the later plays a part in UART baud rate.


I hope it helps.


Regards,

Tomas

0 Kudos
Reply
1,826 Views
chethankumar
Contributor III

Hi Thomas,

Thank you for the reply... I flashed my board with code which i obtained from AN4076SW.zip file. and now board is not getting detected? What might be the issue? And second question is i checked I2C lines of MMA8451Q sensor using Logic Analyser and I2C lines are blank. Nothing transmission Taking place? What might be issue?

Thanks and regards

Chethan

0 Kudos
Reply
1,826 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Chethan,

1. I flashed my board with code which i obtained from AN4076SW.zip file. and now board is not getting detected? What might be the issue?


>> As I wrote before, once you overwrite the original firmware by the AN4076SW, the board is no longer recognized by Sensor Toolbox PC Software (STB GUI) until the bootloader is recovered.


2. And second question is i checked I2C lines of MMA8451Q sensor using Logic Analyser and I2C lines are blank. Nothing transmission Taking place? What might be issue?


>> Did you follow all instructions given in the attached file? What commands are you using to communicate with the MMA8451Q?


Regards,

Tomas


0 Kudos
Reply