M68HC912B32 Serial Interrupt Examples

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

M68HC912B32 Serial Interrupt Examples

2,356 Views
cjw
Contributor I
Hi!

Do any of you know of any good serial interrupt examples in assembler? I searched all over google and newsgroups and found some bits and pieces, but no well commented assembler code that simply shows how to set up the HC12's SCI, retrieve data from the serial port, etc.

Essential, all I want to do is ensure that the SCI is set up to interrupt when the line goes from idle to data. Retrieve the data, store it, and continue the rest of my program. Because I am using an EVB board, it is relatively difficult for me to write code that has visual feedback for me to test whether data is received and if the correct data is received. Hence, it would be very benficial to me to have example code so I could rule out that I am doing something wrong code-wise.

Thanks for all and any help,

Christian
Labels (1)
0 Kudos
1 Reply

381 Views
eeetee
Contributor I

hi:

 

this is for the xdp512, but is generic in nature so you could use it for the b32. it fills a 16 byte buffer with received data, and when the buffer is full it start over again. oddly enough, this weekend i'm writing a complete set of code for the b32 and if you are still having trouble i would give it to you.

 

;sci0 setup

movw #130,sci0bd ;20000000/ (16*130)=9615

movb #0,sci0cr1 ;no loop, enabled in wait,internal tx/rx for loop,1 start 1stop 8bits,idle after no parity

movb #%00101100,sci0cr2 ;int on receive buffer full,tx+rx on,no wakeup, no break

 

;interrupt handler

svc_sci0 ldx #sci0_in_buffer

ldab sci0_in_ptr

ldaa sci0sr1 ;need to read to clear the interrupt

ldaa sci0drl ;fetch data and finish clearing the interrupt bit

staa b,x ;save off the data

cmpb #15 ;test for end of receive array

bhs sci0_buff_full

inc sci0_in_ptr

rti

sci0_buff_full clr sci0_in_ptr

rti

 

 

regards,

 

ed

 

Message Edited by eeetee on 04-13-200604:34 PM

Message Edited by eeetee on 04-13-200604:58 PM

0 Kudos