AnsweredAssumed Answered

Trouble sending a Char using the SCI module of MC9S08SH4MPJ with Device Initialization.

Question asked by Elkin Dario Granados Hernandez on Feb 5, 2013
Latest reply on Feb 26, 2013 by Elkin Dario Granados Hernandez

Hi every one!

 

A few days ago I bought a micro MC9S08SH4MPJ for making a application that reads an ADC channel value and send it to PC with the SCI module. I'm using Codewarriro 6.3, with device initialization. I set the microcontroller for working with the internal clock, I set the internal oscillator frequency in 32.7K and the internal bus clock in 16,74 Mhz. The SCI module is setting for basic use, 8 bit data, no parity, the baud rate divisor in 9 for a baud rate of 116626 bds/s.

 

In the main.c routine I have the following for making a test:

 

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

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

 

#ifdef __cplusplus

extern "C"

#endif

 

char var[]= "Hello world!";  //declaring a char array for test

int i = 0;                   //declaring an int for sending bucle

 

void MCU_init(void); /* Device initialization function declaration */

 

void main(void) {

 

  MCU_init(); /* call Device Initialization */

 

  /* include your code here */

 

//bucle for sending each character of the array

 

for(i=0;i<sizeof(var);i++) {


   sendCharSCI(var[i]);


   }

 

  for(;;) {

    /* __RESET_WATCHDOG(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */

  } /* loop forever */

  /* please make sure that you never leave main */

}

 

//Funtion that sends character for SCI module

 

void sendCharSCI(unsigned char data){

 

  char read = 0;     //variable for rear SCIS1 register

 

  SCIC2_TE = 1;     //enable SCI data transmition

 

  read = SCIS1;     //read SCIS1 register

  SCID = data;     //write the data for sending in SCID register

 

      while (SCIS1_TDRE == 0){ }  //waiting buffer empty

    

      while (SCIS1_TC == 0){ }    // waiting transmition complete

    

  SCIC2_TE = 0;    //disable SCI data transmition

 

}

 

I'm testing the program using and FT232 for simulate a COM PORT. When I check in the hyperteminal the PC is receiving data, but no the same chars of the array. I noted that the received char is the ASCII char + 96. for example, the 'H' is 72 in decimal, then I'm receiving the char 72+96 = 168 that is ' ¨ '.

I don't know if you need any more info, if it, please tell me.

 

I Have a micro coldfire V1 JM128VLD, and I tried to do the same test and works fine!

 

If anybody could help me with this I'll be really grateful!

 

Sorry for my english, Thank you so much and greetings from Colombia!

Outcomes