> I think you might have got some useful help though if
you were asking
> specific questions. All I got was that you are "Running in circle". I
> thought that was what the main loop is supposed to do!
He, he, Computers are a bit like real life, they run in circles but keep getting
interrupted.
Merry midwinter fest to yeah all.
Cheers,
Theo
Reply by JNB●December 26, 20062006-12-26
Thanks for your help and time.
Happy new year
Jnb
Reply by Jefferson Smith●December 26, 20062006-12-26
--- In 6..., "JNB" wrote:
> I try to use C+ that is new for me, and
Codewarrior.
Try C++, it's easier
> Running in circle since a couple of weeks with this
simple clock, did
> somebody got experiences and softwares that can manage IIC?. (with or
> with out IT managment (I try both), I just need simple as possible,
> as RCT seems to be)
I will append my simple IIC code just for fun, but don't complain that
it is for HC12 and not for your MC9S08GB60 (you are asking the wrong
group). The two should be similar anyway.
I think you might have got some useful help though if you were asking
specific questions. All I got was that you are "Running in circle". I
thought that was what the main loop is supposed to do!
;;; Scan switches, and service once when pressed
;;; (not debounced)
Scansw:
;; test switches
ldab sw ; prev sw value in B
movb PTH,sw ; update sw state
eorb sw ; set changed bits
comb ; changed bits are 0
orab sw ; filter out released buttons
bitb #1<<3 ; Sw2: IIC Send
beq Send
bitb #1<<2
beq iic_listen
bra Scansw
Send:
;; send something as master
bsr iic_wait_bus
bset IBCR,#IBMASTER|TXRX ; become master
;; send address (write mode)
ldab #S_ADDR<<1
bsr iic_tx
;; check for Nack
bitb #RXAK
bne 6f ; end if nobody listening
;; send data
ldab tdat
inc tdat
bsr iic_tx
6: movb #IBSLAVE,IBCR ; end transmission
bra Scansw
;;;
;;; Send byte from B to IIC (blocking)
;;;
iic_tx:
stab IBDR
bsr iic_wait
movb IBSR,PORTB ; echo trace
movb #IBIF,IBSR ; clear flg
rts
;;;
;;; Wait until IIC bus not busy
;;;
iic_wait_bus:
brset IBSR,#IBB,iic_wait_bus ; loop until bus available
rts
;;;
;;; Wait until IIC interrupt flg
;;; Returns IBSR status in B
;;;
iic_wait:
;; check for ready flg
brclr IBSR,#IBIF,iic_wait
ldab IBSR
stab PORTB ; echo trace
movb #IBIF,IBSR ; clear flg
;; check for err
bitb #IBAL
bne icc_err
rts
iic_listen:
movb #S_ADDR<<1,IBAD ; slave address
movb #IBSLAVE,IBCR ; slave mode
0: brclr IBSR,#IBIF,0b ; wait for next byte
movb #IBIF,IBSR ; clear flg
brclr IBSR,#IAAS,2f
;; is our addr
brset IBSR,#SRW,icc_respond
bclr IBCR,#TXRX
movw #0,inidx
2:
;; get single byte value
ldab IBDR
stab PORTB
ldx inidx
stab inbuf,x
inx
stx inidx
bra 0b
icc_err:
0: bgnd
bgnd
bra 0b
;;;
;;; Send response as slave
;;;
icc_respond:
bset IBCR,#TXRX ; set to output
0: bra 0b ; unimplemented
I try to use C+ that is new for me, and Codewarrior.
Running in circle since a couple of weeks with this simple clock, did
somebody got experiences and softwares that can manage IIC?. (with or
with out IT managment (I try both), I just need simple as possible,
as RCT seems to be)