in need of sample code 9s08qg8

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

in need of sample code 9s08qg8

3,934 Views
miSta
Contributor I
is there a sample code to use on a demo9s08qg8 to send characters on rs232 port via hypeterm ?

i'm quite new to the hc9s08 and code warrior .. but so far i'm getting the hang of it
i've been playing ard with definitions and sending out via a printf command
and all i got is the character in buffer .. but not in hyperterm ..

thanks ..

Labels (1)
0 Kudos
Reply
8 Replies

790 Views
peg
Senior Contributor IV
Hi miSta,
 
I have attached a CW project that heavily uses the serial port for a user interface. This should have all you need to know plus more.
 
0 Kudos
Reply

790 Views
irob
Contributor V
Yes, the DEMO9S08QG8_APP is very nice for getting an RS232 user interface off the ground. I'm using it as well for this purpose.
0 Kudos
Reply

790 Views
JohnB3
Contributor I
Hi Peg,
 
You referenced a sample of Serial Interface programing code for the QG8.  It was DEMO9S08QG8_APP.ZIP.  I can not open it.  Is it still available in some location where it can be downloaded?  I am learning the QG8 and really learn a bunch from reviewing "already written" code.
 
Thanks
 
John 
0 Kudos
Reply

790 Views
JimDon
Senior Contributor III
Link works for me fine and it opens fine.


Message Edited by JimDon on 2008-02-06 12:02 PM
0 Kudos
Reply

790 Views
Vncnt
Contributor I

This is my code: (SE8)

 

MOV   #$3F,SCID           

MOV   #$3B,SCIC1           

MOV   #$08,SCIC2           

MOV   #$00,SCIBDH     ;9600 Bauds        

MOV   #$1A,SCIBDL      ;9600 Bauds      

MOV   #$FF,PTCDD            

CONT1:  EQU  $080

CONT2:  EQU  $081           

 

PROGRAM:

            JSR   RETA

            NOP

            BSET  0,PTCD

            MOV   #$FF,SCID; Write in SCID Send Datas?

            JSR   N2

            MOV   #$0F,SCID     ; Write in SCID Send Datas?        

    BCLR  0,PTCD

 

            JSR   RETA

            NOP

            BSET  1,PTCD

            LDA   SCID ; Read in SCID Send Datas?

            JSR   N2

            BCLR  1,PTCD

            

           feed_watchdog

           BRA   PROGRAM

RETA:

      MOV   #$FF,CONT2

N2

         MOV   #$FF,CONT1

N1     NOP 

          NOP

          DBNZ  CONT1,N1

          DBNZ  CONT2,N2 

          feed_watchdog

          RTS

 

Is it My configuration in good?, Sending and Reading? anyone used Processor Expert for SCI?, i havent understand which is instruction that used for Reding and Sending.

0 Kudos
Reply

790 Views
RogerSchaefer
Contributor III

Hi,

I have several projects using 9S08QG8; all make use of the SCI and all are in assembly.

http://www.rasmicro.com/DS18B20.htm

 

Roger

 

0 Kudos
Reply

790 Views
ThaManJD
Contributor III
if you include embedded.c into your app and have a look at it you should find it includes a printf function calling terminal.c and those functions in turn calling termio.c. These have to be set up correctly for the QG8 though.
 
Browse through these and see if you can modifiy them to your purpose.
 
here's a couple of clues if youre not too familiar with the SCI module.
 
 
----code snip-----
void fnSCI_Setup(void)
{
   SCIC1= 0;                                              //8 bits no parity
   SCIC2=(SCIC2_TE_MASK)  ;               //trasmit enabled only (no receive), no interrupts
   SCIBDH=0;                                            //these two are used to set up the baud rate
   SCIBDL=0x3B;                                     // values vary depending on how the bus clock is set up.
}
--------code snip---------
 
BAUDRATE=BUS CLOCK/(16XBR)
 
where BR is the lower 13 bits of the WORD combination of SCIBDH and SCIBDL
 
You might consider going into termio.c and changing  the TERMIO_Init function to suit your setup.
You could also create your own setup function and relace the TERMIO_Init calls with your own.
 
Notice in termio.c that the functions are using different methods depending on compile options. Different processors have their bit options in different places etc and the register names differ. If there's no suitable code in any of the options, you'll have to insert your own.
 
The SCI setup/init should be done before using printf.
 
John Dowdell
 
 
0 Kudos
Reply

790 Views
bigmac
Specialist III
Hello,
 
When using a low level device with very limited resources, such as the S08QG8, I would be very wary about using library functions such as printf or sprintf.  Because of the many data formatting options available, they are complex functions that will consume a very significant portion of available MCU resources.
 
If your requirement is to send ASCII message data, you will consume far less of the resources by using a SCI character send function directly, in order to send string data.
 
Regards,
Mac
 
0 Kudos
Reply