Hello Pankaj, Paul and MAC,
I have been spending some days with a problem that I think it's the same Pankaj had. I am using MC9S08QG8 uC on my application, have to use a IIC and SCI interfaces, both works well (I think) on debbuging; but when I programmed as a standalone it does not seem to be in the endless loop.
I have commented the WATCHDOG() line, and it only works on debbuing when transfering to a PC through a PC, I am using codewarrior 10.2;
Function: u8LM92ReadRegister(0x00), returns a zero when a reading is completed.
I did all you said; but it does not work!
#define Disable_COP() SOPT1 = 0x52; | // Deshabilitar COP watchdog y habilitar BDM |
#define PTB4_On() PTBD_PTBD4 = 1;
#define PTB4_Off()PTBD_PTBD4 = 0; |
void SCI_ini(byte SCIC1_Config,byte SCIC2_Config,short SCIBD_Config);
void Send_Data(const unsigned char *Vec,byte TAM);
void Dummy_send(void);
extern float Temperatura;
float f;
const unsigned char tempo[2];
int i=0;
byte *pTx;
void main(void) {
EnableInterrupts;
/* include your code here */
Disable_COP();
/* Initialization registers */
ICSTRM = *(unsigned char*far)0xFFAF; /* Initialize ICSTRM register from a non volatile memory */
ICSC1 = 0x04; /* ICSC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=0,IREFSTEN=0 */
ICSC2 = 0x00; /* ICSC2: BDIV=1,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 */
ICSSC = 00; /* Initialize ICSSC register from a non volatile memory */
PTBDD_PTBDD4 = 1; | // set PTB4 as output |
init_I2C();
SCI_ini(0x00,0x0C,0x1A);
Dummy_send();
for(;;) {
//__RESET_WATCHDOG(); | /* feeds the dog */ | |||||||
if(!u8LM92ReadRegister(0x00)) { | ||||||||
Temperatura; | ||||||||
if(Temperatura>30.00){ | ||||||||
PTB4_On(); | ||||||||
}else{ | ||||||||
PTB4_Off(); | ||||||||
} | ||||||||
} | ||||||||
} /* loop forever */
/* please make sure that you never leave main */
}