ICC12's Hello world does not work on my 9s12dp256

Started by zhao47803 August 5, 2003
Hi,

I need your help!

I cannot have the "Hello World" example that comes with ICC12 work
for my 9s12dp256 board.

I tried to include "hcs12dp256.h" in my project instead of "hc12.h".
But the program still does not work.

Then, I commented out the "puts" statement and wrote several lines of
code to toggle port b. The program works ok.

What is the trick? Why only "puts" and "printf" statements do not
work?

Any help and suggestions will be greatly appreciated.

Lin



In a message dated 8/5/03 3:11:29 PM Eastern Daylight Time,
writes:
Any help and suggestions will be greatly appreciated
======================================

I think there is a setbaud() function that will init the serial port to some
default paramaters.... anything fancy you need to write an initsci() function
to get the baud rate, stop bits etc correct


I had the same problem migrating from a 68hc12.
Imagecraft sent me two files to add to the project's
file list:

*************
serial.c
/* #include <hcs12dp256.h> for S12DP256 */
#include <hcs12dp256.h>

/* This assumes a 8 MHz clock. If not, you'll need to change the
* Baud rate enum.
*/
void setbaud(BaudRate baud)
{
SC0BD = baud;
/* enable transmitter and receiver */
SC0CR2 = 0x0C;
}
***************
putchar.c
//#include <stdio.h>
#define _SCI
/* #include <hcs12dp256.h for S12DP256 */
#include <hcs12dp256.h>

extern int _textmode;

int putchar(char c)
{
if (_textmode && c == '\n')
putchar('\r');
while ((SC0SR1 & TDRE) == 0)
;
SC0DRL = c;
return c;
}
*******************
I also had to hack at their hcs12dp256.h file. I know this
wasn't the best (by far) way to do it, but it worked.

/* I hacked at the file from here */
#define SCI0BDH _P(0xC8)
#define SCI0BDL _P(0xC9)
#define SC0BD _LP(0xC8)
//#define SCI0BD _LP(0xC8)
#define SC0CR1 _P(0xCA)
#define SCI0CR1 _P(0xCA)
#define SC0CR2 _P(0xCB)
//#define SCI0CR2 _P(0xCB)
/* SCI bits */ /*NA 5/20/03 */
#define PF bit(0)
#define FE bit(1)
#define RE bit(2)
#define TE bit(3)
#define IDLE bit(4)
#define RDRF bit(5)
#define TC bit(6)
#define T8 bit(6)
#define TDRE bit(7)
#define R8 bit(7)
/*NA 5/20/03 */
#define SCI0SR1 _P(0xCC)
#define SC0SR1 _P(0xCC) /*NA 5/20/03 */ /* compatability */
/* #define SC0SR1 SCI0SR1 */ /* compatability */
#define SC0SR2 _P(0xCD)
#define SCI0SR2 _P(0xCD)
#define SCI0DRH _P(0xCE)
#define SCI0DRL _P(0xCF)
#define SC0DRL _P(0xCF) /*NA 5/20/03 */ /* compatability */
/* #define SC0DRL SCI0DRL */ /* compatability */
#define SCI0DR _LP(0xCE)
/* to here */

Good luck
Nick

> -----Original Message-----
> From: zhao47803 [mailto:]
> Sent: Tuesday, August 05, 2003 3:09 PM
> To:
> Subject: [68HC12] ICC12's Hello world does not work on my 9s12dp256 > Hi,
>
> I need your help!
>
> I cannot have the "Hello World" example that comes with ICC12 work
> for my 9s12dp256 board.
>
> I tried to include "hcs12dp256.h" in my project instead of "hc12.h".
> But the program still does not work.
>
> Then, I commented out the "puts" statement and wrote several lines of
> code to toggle port b. The program works ok.
>
> What is the trick? Why only "puts" and "printf" statements do not
> work?
>
> Any help and suggestions will be greatly appreciated.
>
> Lin >
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
> Printer at Myinks.com. Free s/h on orders $50 or more to the
> US & Canada. http://www.c1tracking.com/l.asp?cidU11
> http://us.click.yahoo.com/sO0ANB/LIdGAA/ySSFAA/dN_tlB/TM
> --------------------------
> -------~->
>
> -------------------- >
> ">http://docs.yahoo.com/info/terms/




Hi Nick,

Thank you so much. By following your instructions, my program works
now.

Lin
--- In , "Allen, Nick" <nick.allen@t...> wrote:
> I had the same problem migrating from a 68hc12.
> Imagecraft sent me two files to add to the project's
> file list:
>
> *************
> serial.c
> /* #include <hcs12dp256.h> for S12DP256 */
> #include <hcs12dp256.h>
>
> /* This assumes a 8 MHz clock. If not, you'll need to change the
> * Baud rate enum.
> */
> void setbaud(BaudRate baud)
> {
> SC0BD = baud;
> /* enable transmitter and receiver */
> SC0CR2 = 0x0C;
> }
> ***************
> putchar.c
> //#include <stdio.h>
> #define _SCI
> /* #include <hcs12dp256.h for S12DP256 */
> #include <hcs12dp256.h>
>
> extern int _textmode;
>
> int putchar(char c)
> {
> if (_textmode && c == '\n')
> putchar('\r');
> while ((SC0SR1 & TDRE) == 0)
> ;
> SC0DRL = c;
> return c;
> }
> *******************
> I also had to hack at their hcs12dp256.h file. I know this
> wasn't the best (by far) way to do it, but it worked.
>
> /* I hacked at the file from here */
> #define SCI0BDH _P(0xC8)
> #define SCI0BDL _P(0xC9)
> #define SC0BD _LP(0xC8)
> //#define SCI0BD _LP(0xC8)
> #define SC0CR1 _P(0xCA)
> #define SCI0CR1 _P(0xCA)
> #define SC0CR2 _P(0xCB)
> //#define SCI0CR2 _P(0xCB)
> /* SCI bits */ /*NA 5/20/03 */
> #define PF bit(0)
> #define FE bit(1)
> #define RE bit(2)
> #define TE bit(3)
> #define IDLE bit(4)
> #define RDRF bit(5)
> #define TC bit(6)
> #define T8 bit(6)
> #define TDRE bit(7)
> #define R8 bit(7)
> /*NA 5/20/03 */
> #define SCI0SR1 _P(0xCC)
> #define SC0SR1 _P(0xCC) /*NA 5/20/03 */ /* compatability */
> /* #define SC0SR1 SCI0SR1 */ /* compatability */
> #define SC0SR2 _P(0xCD)
> #define SCI0SR2 _P(0xCD)
> #define SCI0DRH _P(0xCE)
> #define SCI0DRL _P(0xCF)
> #define SC0DRL _P(0xCF) /*NA 5/20/03 */ /* compatability */
> /* #define SC0DRL SCI0DRL */ /* compatability */
> #define SCI0DR _LP(0xCE)
> /* to here */
>
> Good luck
> Nick >
>
> > -----Original Message-----
> > From: zhao47803 [mailto:lin.zhao@r...]
> > Sent: Tuesday, August 05, 2003 3:09 PM
> > To:
> > Subject: [68HC12] ICC12's Hello world does not work on my
9s12dp256
> >
> >
> > Hi,
> >
> > I need your help!
> >
> > I cannot have the "Hello World" example that comes with ICC12
work
> > for my 9s12dp256 board.
> >
> > I tried to include "hcs12dp256.h" in my project instead
of "hc12.h".
> > But the program still does not work.
> >
> > Then, I commented out the "puts" statement and wrote several
lines of
> > code to toggle port b. The program works ok.
> >
> > What is the trick? Why only "puts" and "printf" statements do not
> > work?
> >
> > Any help and suggestions will be greatly appreciated.
> >
> > Lin
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> > ---------------------~-->
> > Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or
Lexmark
> > Printer at Myinks.com. Free s/h on orders $50 or more to the
> > US & Canada. http://www.c1tracking.com/l.asp?cidU11
> > http://us.click.yahoo.com/sO0ANB/LIdGAA/ySSFAA/dN_tlB/TM
> > --------------------------
> > -------~->
> >
> > --------------------
> >
> >
> >
> > ">http://docs.yahoo.com/info/terms/
> >
> >