David LECOMTE

DEMO09S08QE8

Discussion created by David LECOMTE on May 18, 2009
Latest reply on May 20, 2009 by Fabio Pereira

When I load and run following program with True Time Simulator & Real Time Debugger ther is no problem. The "Hello World" word appears in terminal windows. But when i reset my microprocessor with K6 system power connector, a specific caracters appears in my terminal windows instead of "Hello World"

Thanks for your help.

David

 

#define LED2  PTCD_PTCD0
unsigned int i;
unsigned char j;
// This is a simple string to serial function
void SCI_send_string(char *string)
{
  while (*string)         // while the current char of the string is not null
  {
    while (!SCIS1_TDRE);  // wait for the transmit buffer to be empty
    SCID = *string;       // write the current char into the transmit buffer
    //for (i=0;i<512;i++){
    //  for(j=0;j<255;j++)
    //        asm("nop");
    //}
    //LED2 = !LED2;         // toggle the led
    string++;             // increment the current char position within the string
  }
}

void main(void)
{
  char rxchar;
 
  SOPT1_COPE = 0;
  SOPT1_BKGDPE = 1;        // 1 = enable the debug pin | 0=disable debug pin
  ICSC2_BDIV0 = 1;
  ICSC2_BDIV1 = 0;
 
 
//  SOPT1_BKGDPE = 1;
 
 
  PTCDD_PTCDD0 = 1;       // PTC0 as an output
 
 
  // Following a reset, BUSCLK = 4MHz
  SCIBD = 26;             // SCI baud rate = 4MHz/(16*26)=9615 bps
  SCIC2_TE = 1;      // enable the transmitter section
  SCIC2_RE = 1;      // enable the transmitter section
  SCI_send_string("Hello World!");  // write into the serial port ...
 
  while(1)
  {
    while (!SCIS1_RDRF);  // wait for a new character to be received
    //while (!SCIS1_TDRE);  // wait for the transmit buffer to be empty
    rxchar = SCID;        // read the received char
    SCID = rxchar;        // send the char back to the host PC
    LED2 = !LED2;         // toggle the led
    if (rxchar==13) SCI_send_string("\r\nHCS08 rules!\r\n");
  }
}

Outcomes