Web Analytics Made Easy -
StatCounter Software design for HC12 - CodingForum


No announcement yet.

Software design for HC12

  • Filter
  • Time
  • Show
Clear All
new posts

  • Software design for HC12

    If i have to write an assembly language subroutine called Start, to initialise the Analog to Digital (ATD) ready to operate as required in Part 2 below for the MC68hc912D60A microprocessor.

    Part 2.
    Write an assembly language subroutine called TEMPIN that starts an 8 bit, left justified ATD conversion on channel 0, waits for the conversion to complete, reads the resulting data and returns the raw data reading in accumulator B. The raw data reading returned will be a positive number, $00 through to $A0 (decimal=160). This number is a measure of the temperature in steps of 0.25 C. For example an ATD value of $20 (decimal=32) equates to
    32*0.25 = 8 C. Although larger numbers are possible from the ATD, the maximum range of values you can expect is 0 to 160 (0 - 40 C). Do not do any conversion in this routine

    further into the task there are other sub routine called
    - scale
    -initialize timer

    Am i write by assembling the following code to initalise the

    TEMPIN EQU $0200 ;Memory location for temp in
    SCALE EQU $0201 ;Memory for scale
    INITMR EQU $0202 ;Memory to initalise timer
    DELAY EQU $0203 ;Memory for timer delay
    SPLIT EQU $0204 ;Memory for converting temperature
    DISPLAY EQU $0205 ;Memory for digital display
    PAD0 EQU $006F ;Memory location for temperature input
    PORTT7 EQU $00AE ;Memory location for alarm
    PORTT0 EQU $00AE ;Memory location for degrees c or f voltage

    there is a diagram of the chip in the attachment where all the ports can been seen.

    if anyone can provide me some information to whether i am correct or not that would be helpful.

    Attached Files
    Last edited by arnette; Apr 6, 2009, 08:51 AM.

  • #2

    To write to the ATD register, you'd need to load the value into register say A, and then write A to the location. I haven't touched assembly for a long time, and no longer have hc12 manual, so the syntax is approximate:

    ldx     BASE_ADDR
    ldaa    #somevalue
    sta     8,x
    you need to follow the steps in the manual of initializing ATD and write one value at a time, and then check the status register until conversion is done, read in the value.

    hope that helps.
    Teach me to be a software engineer, I don't care if it takes a whole day to learn it.
    Feel ready? Test yourself with some Interview questions