how to run s08 without bdm?

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

how to run s08 without bdm?

2,557 Views
trav
Contributor III
So I have a demoQE board, and I want it to run on it's own without having to be hooked up to the computer, how do I do this?
Labels (1)
0 Kudos
8 Replies

853 Views
trav
Contributor III
no one?
0 Kudos

853 Views
peg
Senior Contributor IV

Hi Trav,

 

Given that you should not have to do anything special other than to arrange for a different power supply other than the one provided by the USB cable, you probably should be telling us what your EXACT problem is with this.

 

0 Kudos

853 Views
trav
Contributor III
Well I can run the board off of batteries, and it lights up but doesn't do what it's suppose to.  It's suppose to initialize a LCD but never does. The only way I can get it to run is thru the simulator.
0 Kudos

853 Views
trav
Contributor III
Ok here is a question, if I pull reset low, the mcu should restart my code all over from the beginning? or from where it left off?
0 Kudos

853 Views
peg
Senior Contributor IV

Hi trav,

 

When the MPU is reset code execution will jump back to the beginning or more precisely it will jump to the location programmed into the reset vector.

You do have the reset vector set, don't you?

This could be the cause of your problem.

0 Kudos

853 Views
trav
Contributor III

This is in the MC9S08QE128.h file

 

#define Vreset                          0x0000FFFE

 

 

This is at the end of the Project.prm file

VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */

 

 And this at the end of the Start08.c file

 

__EXTERN_C void _Startup(void) {/* set the reset vector to _Startup in the linker parameter file (*.prm):    'VECTOR 0 _Startup'    purpose:    1)  initialize the stack                2)  initialize run-time, ...                    initialize the RAM, copy down init data, etc (Init)                3)  call main;    called from: _PRESTART-code generated by the Linker*/  INIT_SP_FROM_STARTUP_DESC();#ifndef  __ONLY_INIT_SP  Init();#endif#ifndef __BANKED__  __asm JMP main; /* with a C style main(); we would push the return address on the stack wasting 2 RAM bytes */#else  __asm CALL main;#endif}

 


 

 

I'm not quite sure what I am suppose to be looking for.

 

Travis

 

Message Edited by trav on 2009-03-29 12:47 PM
0 Kudos

853 Views
trav
Contributor III
Figured out my problem, when it's not hooked up to the BDM the clock runs faster, my delay use a for loop (ya I know I'm lazy).  I didn't realize under BDM it would use a slower clock speed.
0 Kudos

853 Views
trav
Contributor III

Here is what I have code wise so far.

 

 

#include <hidef.h> /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */#include <stdio.h>/* Define a shortname for variable types */ typedef unsigned char    UINT8;  /*  8 bits */typedef unsigned short int UINT16; /* 16 bits */typedef unsigned long int  UINT32; /* 32 bits */typedef signed char     INT8;   /*  8 bits */typedef signed short int  INT16;  /* 16 bits */typedef signed long int   INT32;  /* 32 bits */typedef volatile UINT8   VUINT8;  /*  8 bits */typedef volatile UINT16   VUINT16; /* 16 bits */typedef volatile UINT32   VUINT32; /* 32 bits *///Register select line#define LCD_RSH (PTDD_PTDD4= 1);#define LCD_RSL (PTDD_PTDD4= 0);//Read/Write#define LCD_RWH (PTDD_PTDD5= 1);#define LCD_RWL (PTDD_PTDD5= 0);//Enable line#define LCD_EH (PTDD_PTDD6 = 1);#define LCD_EL (PTDD_PTDD6 = 0);#define LCD_STROBE_E ((PTDD_PTDD6 = 1),(delay(0xF)),(PTDD_PTDD6=0));UINT16 ones, tenths, hundredths;UINT16 adc_val;UINT32 temp;char volts[10];void initSystems(void), InitADC(void), SetADC(byte, byte);void initLCD(void), LCDCmd(UINT8), LCDChar(UINT8), dsplyString(UINT8 *);void delay(UINT8);void main(void) {    initSystems();  InitADC();  initLCD();  SetADC(0x0A,0x01);                      // ADC10, enable interrupt  EnableInterrupts;                       /* enable interrupts */     LCDCmd(0x0C);          while(1){      temp = (ulong)adc_val * 7662; //7324 for 3V      ones = temp / 10000000;      temp = (temp - (10000000* ones));      tenths = temp/1000000;      temp = (temp - (1000000*tenths));      hundredths = temp /100000;      sprintf(volts, "gm:%d.%d%d",  ones, tenths, hundredths);      dsplyString(volts);      LCDCmd(0x02);      delay(0xFFFF);    } }/************************** System Initializations ***************************/void initSystems() {    SOPT1  = 0x00;                          // Disable COP,RSTO, enable BKGD,RESET  SOPT2  = 0x00;                          //   SPMSC1 = 0x00;                          // Disable LVD  SPMSC2 = 0x00;                          // Disable power-down modes  SPMSC3 = 0x00;                          // Disable LVWIE, low trip points  SCGC1  = 0xFF;                          // Enable bus clock to ADC   SCGC2  = 0xFF;                          // } /*************************** ADC Initialization *******************************/void InitADC(void) {    ADCCFG = 0x17;  ADCSC2 = 0x00;  ADCSC1 = 0x00;    ADCSC1_ADCO = 1;      //hardware trigger interrupt    APCTL2 = 0x04; } /**************************  SetADC to pick ADC Channel  **********************/void SetADC(byte adc_channel, byte aien_value) {  ADCSC1_AIEN = aien_value&0x01;  ADCSC1_ADCH = adc_channel;}/***************************  ADC Interrupt  ****************************/interrupt VectorNumber_Vadc void   ADC_ISR(void) {  if(ADCSC1_COCO ==1)    adc_val = ADCR;}/***************************  LCD Connections  ****************************4-bit modePTD0-PTD3 = DB4-DB7   Data busPTD4      = RS        Register selectPTD5      = R/W       Read / WritePTD6      = E         EnablePORTD 0b00000000         |||||||         |||---- data bus  0x0F         |||---- RS        0x10         ||----- R/W       0x20         |------ Enable    0x40  */        /***************************  Initialization of LCD  ************************/void initLCD(void) {     PTDDD = 0xFF;                       //Set PortC as output    PTDD = 0x00;                        //Set PortC outputs to 0x00    LCD_RWL;                            //Make sure it's in Write mode        PTDD=0x03;  LCD_STROBE_E;   delay(0xFF);        PTDD=0x03;  LCD_STROBE_E;   delay(0xF);            PTDD=0x03;  LCD_STROBE_E;   delay(0xF);        PTDD=0x02;  LCD_STROBE_E;   delay(0xF);            LCDCmd(0x28);    LCDCmd(0x08);    LCDCmd(0x01);    LCDCmd(0x06);    LCDCmd(0x0F);}/****************************  LCD Commands  ****************************//*0x01; clears screen0x38; sets up the display initalization0x0F; turns display on0x06; sets the cursor on and blinking0x02; move cursor to start and don't destroy data0x18; shifts cursor to the left when a char is entered0x1C; shifts cursor to the right when a char is entered0x10; moves 1 char to the left0x14; moves 1 char to the right0x80; add this to the address of the display to set the cursor position wanted*/void LCDCmd(UINT8 ch) {    UINT8 ln, un;    //lower and upper nibble    ln = ch & 0x0F;    un = ch >>4;    delay(0xFF);    PTDD = un;    LCD_STROBE_E;           delay(0xFF);      PTDD = ln;    LCD_STROBE_E;    }/**********************  Places a Char on LCD screen  ***********************/void LCDChar(UINT8 ch) {    UINT8 ln, un;    //lower and upper nibble    ln = ch & 0x0F;    un = ch >>4;        //upper nibble first    PTDD = un;    LCD_RSH;  LCD_STROBE_E            //lower nibble    PTDD = ln;    LCD_RSH;  LCD_STROBE_E;                LCD_RSL;}/************************  Places a String on LCD screen  ********************/void dsplyString(UINT8 *msgptr) {  while(*msgptr){    LCDChar( *msgptr);    msgptr++;  }}/*************************   delay code  ***************************/void delay(UINT8 cnt){ int i;  for(i=0;i<cnt;i++){  }} 

 

 

 

0 Kudos