Newbie question about "Serial communication with MC9S12HC32"

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

Newbie question about "Serial communication with MC9S12HC32"

3,505 Views
M3H0
Contributor I
Hi,
 
I'm working with a MC9S12C32 and I'm trying to communicate the MCU with the PC using the SCI port. I have read the application note AN1774 and I have succeed sending a byte and reading a byte using the serial port.
 
Now I would like to use the printf() function and the rest of the functions from the stdio.h file, since as I have read in the application note, there is a specific function used to send all the bytes contained in the "SCIstring".
 
I have tried something, but it doesn't work. Can anyone send me a copy of a working program in which those functions (those contained in stdio.h file) are used? Or can anyone tall me how can I do that?
 
THX in advance
Oroitz
Labels (1)
0 Kudos
6 Replies

782 Views
EagleBeak
Contributor I
Hi,
 
I haven't used the printf() but I do use the sprintf function to format messages. Not perfectly clear about what you're trying to do but you can implement a few lines of code to fire off the contents of a buffer.
 
Set a pointer such as *ptr to point to the beginning of your buffer, then enable the serial interrupt. When the interrupt happens load the serial data register with the character, increment the pointer to the next character. The routine stops when *ptr is pointing at the terminating zero.
 
if(*ptr)
 SCIODRL = *ptr ;
 ptr++ ;
}
 
Hope this helps,
E. Beak
0 Kudos

782 Views
M3H0
Contributor I
Hi eagle break!
 
First of all, thank you for having answered to my message. I have been working with microchip microcontrollers for the last 6 years in a microrrobtic laboratory in my university (as student), but know we have decided to migrate into motorola´s MCUs which we have been told that are quite better than the others.
 
I started working with the MC9S12C32 MCU, using the Chips12 board, and Imagecraft´s ICC12 IDE & compiler, and though I have realized that in fact those MCUs are better than Microchip´s, they are quite more complicated to understand and to use than the other ones (at list at the beginning), since we used the MPLAB IDE (downloable for free in the Microchip´s web page) and the CCS C compiler which have a user manual in which there are explained the many built-in functions that the compiler has.
 
After this lesson of history.... what I´m actually trying to do is to learn how to use the MCU. I have been reading all the documentation I have about it, and try to control the diferent modules contained in it. I have succeed controlling most of it´s features but now I´m clogged with the SCI module, trying to make a very simple "Hello world!" kind application using the functions contained in the "stdio.h" header file (puts, putchar, printf...).
 
I read the AN2883 application note and I got to send and receive single bytes using the serial port with the Hyperterminal (using SCI´s interruptions but without using the stdio.h header file). After that I tryed to send strings using the printf() function and it didn´t work, and as I am a bit lost yet, I don´t know even from where I should start looking.
 
I attach my actual code, just in case some wants to have a look at it and tell me what I´m doing wrong.
 
Thank you very much again, for your answer
Oroitz
 
 
0 Kudos

782 Views
j0hnny_brav0
Contributor I
Hi there!
I'm working on the same sci problem as you are. I'd like to know, as you said you managed to send bytes on the sci, how could you see what bytes you've send.

Regards!
0 Kudos

782 Views
M3H0
Contributor I
Hi there!

You have to ways of knowing which bytes you have sent:

- One of them is checking the value of the corresponding register in the SCI module(SCIDRH/L).

- The other (prefered way) is using a console program for serial communication on your PC (i.e Hyperterminal) where you can see all what the microcontroller sends via the serial port.

See ya!
M3H0
0 Kudos

782 Views
M3H0
Contributor I
I´m sorry, the application note mentioned in the previous message was wrong, the actual application note is AN2883
 
Oroitz
0 Kudos

782 Views
kris_techlabs
Contributor I
Hello,
  I am trying to send a byte from MCU to a computer using SCI in mC9S12C32 using the CSM-12C32 board ,written a program in Codewarrior.I have put baud rate as 9600,on my board there is 16Mhz crystal oscillator ,so i had taken 8mhz as machine frequency ,i initiated the communication.Strangely i could not send any byte ,as SCISR1's TDRE i am polling ,it remains set always and whenever i wrote this statement SCIDRL='h' ,data is not going to the register at all..Can u send me any code in c to send a simple character..please its urgent..
 
Thank you very much
0 Kudos