QG8 ASM sample code

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

QG8 ASM sample code

6,038件の閲覧回数
admin
Specialist II
Hi guys,
I was wondering if there are any online resources on asm sample codes? Such as setting up port B for output and ADC etc.... am trying to migrate to QG8 from the hc11 and it has been a while since I did my project on that so am very rusty at the moment....

Thanks in advance!
ラベル(1)
0 件の賞賛
返信
8 返答(返信)

1,223件の閲覧回数
joerg
Contributor II
Hi
why not have a look at EBS08
see: www.systech-gmbh.ch -> EBS08

Saluti Joerg
0 件の賞賛
返信

1,223件の閲覧回数
admin
Specialist II
Thank you Joerg!

More of these type of links would be welcome, thank you everyone.
0 件の賞賛
返信

1,223件の閲覧回数
bigmac
Specialist III
Hello,
 
I might suggest that you use the "standardised" register names, contained within the file mc9s08qg8.inc, to be found within the CodeWarrior installation  (..\lib\hc08\device\asm_include\).  This file can then be INCLUDEd near the beginning of your main .asm file.
 
If you find that some of the standard bit names for the peripheral registers are a little unwieldy, it is possible to substitute an alias, for those bits specifically referenced by the code, e.g.
 
CPHA  EQU  SPIC1_CPHA ; Define alias for CPHA bit
 
BSET  CPHA,SPIC1
can then be used, rather than
BSET  SPIC1_CPHA,SPIC1
 
I suggest the following check list for initialisation purposes, for the QG8.  Some of the intialisation will not be necessary if the peripheral is not used within the particular project.  In most instances, the peripheral use of IO pins will over-ride their GPIO use.
 
System options
System power management
ISC module
GPIO pins
 
KBI module
IRQ
 
TPM module
TPM channels
MTIM module
 
ADC module
Analog comparator
 
SCI module
SPI module
IIC module
 
Most projects are likely to require at least the first four categories.
 
For an assembly project, a further decision will be whether to use relocatable assembly or absolute assembly.  The use of the ORG directive would indicate absolute assembly (although the position of the directive is probably incorrect).
 
Regards,
Mac
0 件の賞賛
返信

1,223件の閲覧回数
admin
Specialist II
Hi Mac,
Thank you for your suggestion.

Do you know what is the standard absolute essential set up routine(code) in order for the program to work?  Not including  modules  for the project and additonal features....

For example, I found this part in the QG8 sample code in code warrior

ldhx   #$25F       
txs                       ;Initialize Stack Pointer

I think this initialization would be absolute enssetial for any program to work because I remeber when I was using in HC11 there is a same initialization required which is

stack equ $00c6

lds #stack

Since I am using internal clock source, I would think this would be the absolute essential set up routine required for every program using internal clock source on top of additional module initialization ?

            ldhx   #$25F       
            txs                                   ;Initialize Stack Pointer
            lda   #%01000110          ;clock set up
            sta   ICS1
            lda   #%00000000        
            sta   ICS2

Thanks!

 
0 件の賞賛
返信

1,223件の閲覧回数
bigmac
Specialist III
Hello,
 
Yes, I did happen to omit stack initialisation from the previous check list.  This is so fundamental, it should be the first thing done on entry to the program, normally to set the stack pointer to "end of RAM".  Symbolically, this is done with the following code -
 
     org   ROMStart
 
Startup_:
     ldhx  #RAMEnd+1
     txs
     ...
 
Note that the value in the stack pointer will be one less than the H:X value.
 
A further essential item that was omitted from the check list, to set the reset vector to the start of your code.  For an absolute assembly program, the following code should be present at the end of the .asm file -
 
      org   Vreset
      dc.w  Startup_
 
Of course, if the project requires use of other interrupt vectors, these should also be initialised in a similar manner.
 
For the following items, you should at least check whether the default register settings meet the specific requirements of the project.
 
System options:
SOPT1, SOPT2 registers
System power management:
SPMSC1, SPMSC2, SPMSC3 registers
ISC module:
ICS1, ICS2 registers
GPIO pins, port A:
PTAD, PTADD, PTAPE, PTASE, PTADS
GPIO pins, port B:
PTBD,PTBDD,PTBPE, PTBSE, PTBDS
 
In many instances, the default settings may suffice, but you will need to check anyway.  Suitable initialisation of unused GPIO pins is just as important as for the pins that are used by the project, to prevent any input from floating at an indeterminate voltage level.
 
Regards,
Mac
 
0 件の賞賛
返信

1,223件の閲覧回数
admin
Specialist II
Hi Mac,
Thank you so much for your help to put me on the right track, I can not wait to overcome the elementary initialization procedures in order to make use of the micro.

Can you direct me to the text where it covers the code

org   Vreset
dc.w  Startup_

I am lost on this particular command

dc.w

Can not find that in the instruction set, so I guess its not an instruction?

Thank you so much for your guidance!
regards,
 


Message Edited by Learner on 2007-12-30 09:36 AM
0 件の賞賛
返信

1,223件の閲覧回数
bigmac
Specialist III
Hello,


Learner wrote:

org   Vreset
dc.w  Startup_

I am lost on this particular command

dc.w

Can not find that in the instruction set, so I guess its not an instruction?


This is an assembler directive (org is also a directive).  It means to "define a constant word" at the current address, i.e. the word value is the address of Startup_ label.
 
I assumed that you were using CW assembler.  If you are using a different assembler, the directives may differ from the ones I have used.  The various CW assembler directives can be found in the assembler manual, within the CW installation (possibly ...\Help\pdf\Assembler_HC08.pdf).
 
Regards,
Mac
 


Message Edited by bigmac on 2007-12-30 10:41 PM
0 件の賞賛
返信

1,223件の閲覧回数
admin
Specialist II
Hi,
I was wondering if someone can take a look at my asm and let me know if the set up code is enough to get the QG8 going?

ZERO           equ   $3f                 ;7 segment LED
ONE             equ   $06
TWO            equ   $5b
THREE        equ   $4f
FOUR           equ   $66
FIVE             equ   $6d
SIX               equ   $7c
SEVEN         equ   $07
EIGHT          equ   $7f
NINE            equ   $67
DOT             equ   $80

START        equ   $e000               ;FLASH
PORTB       equ   $0002
PRTBD       equ   $0003               ;port B direction 
ICS1            equ   $0038               ;clock source
ICS2             equ   $0039               ;bus frequency


;setup
           
            lda   #%01000110          ;clock set up
            sta   ICS1
            lda   #%00000000        
            sta   ICS2
            lda   #%11111111          ;setup portB as output                   
            sta   PRTBD              
asm_main           
                                                                                                         
            org   START
            lda   ZERO        
            sta   PORTB               ;turn on 7 segment
           
            lda   #%00001111
            sta   PORTB
again       deca 
            cmpa  #%0
            bne   again
            lda   #%00000000
            sta   PORTB

the code passes the debug stage but how do I use the real time sim/debugger and load this into the QG8? I apologise for such a elementary question...
0 件の賞賛
返信