This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Temp Meter

I am working on a design using the on-chip temperature sensor:
Displays the room temperature in a LCD
and lights an array of six led's blinking to
form a christmas tree.

Need assistance in C or assembler ...

Parents
  • ; SUBROUTINES
    ;-
    ; Timer3_Init
    ;
    ; Routine initializes Timer3 in 16-bit auto-reload mode to overflow
    ; at 100Hz using SYSCLK/12 as its time base. Exits with Timer3
    ; stopped and Timer3 interrupts disabled.
    ;
    Timer3_Init:
    mov TMR3CN, #00h ; stop Timer3, clear TF3, use
    ; SYSCLK/12 as timebase
    mov TMR3RLH, #HIGH(-TC_10ms); init reload values
    mov TMR3RLL, #LOW(-TC_10ms)
    mov TMR3H, #0ffh ; set to auto-reload immediately
    mov TMR3L, #0ffh
    anl EIE2, #NOT(01h) ; disable Timer3 interrupts
    ret
    ;
    ; TIMER3_Start
    ; This routine starts Timer3
    ;
    Timer3_Start:
    orl TMR3CN, #04h ; set TR3
    ret
    ;
    ; Initialize ADC0 for left-justified mode monitoring the
    ; on-chip temp sensor at a gain of '2'. Leaves ADC in disabled state.

    ADC0_Init:
    clr ADCEN ; disable ADC
    mov REF0CN, #07h ; enable temp sensor, bias
    ; generator, and output
    ; buffer
    mov AMX0SL, #0fh ; select TEMP sensor as ADC0
    ; input
    mov ADC0CF, #80h ; set SAR clock to SYSCLK/16
    orl ADC0CF, #01h ; PGA Gain = 2
    mov ADC0CN, #45h ; ADC disabled, low power
    ; track mode, ADC0 conversions
    ; initiated by overflow on
    ; Timer3, left-justified data
    ret
    ;
    ; This routine enables the ADC and ADC interrupts.
    ADC0_Enable:
    setb ADCEN ; enable ADC
    orl EIE2, #02h ; enable ADC EOC interrupt
    ret;
    ; End of file.
    END

Reply
  • ; SUBROUTINES
    ;-
    ; Timer3_Init
    ;
    ; Routine initializes Timer3 in 16-bit auto-reload mode to overflow
    ; at 100Hz using SYSCLK/12 as its time base. Exits with Timer3
    ; stopped and Timer3 interrupts disabled.
    ;
    Timer3_Init:
    mov TMR3CN, #00h ; stop Timer3, clear TF3, use
    ; SYSCLK/12 as timebase
    mov TMR3RLH, #HIGH(-TC_10ms); init reload values
    mov TMR3RLL, #LOW(-TC_10ms)
    mov TMR3H, #0ffh ; set to auto-reload immediately
    mov TMR3L, #0ffh
    anl EIE2, #NOT(01h) ; disable Timer3 interrupts
    ret
    ;
    ; TIMER3_Start
    ; This routine starts Timer3
    ;
    Timer3_Start:
    orl TMR3CN, #04h ; set TR3
    ret
    ;
    ; Initialize ADC0 for left-justified mode monitoring the
    ; on-chip temp sensor at a gain of '2'. Leaves ADC in disabled state.

    ADC0_Init:
    clr ADCEN ; disable ADC
    mov REF0CN, #07h ; enable temp sensor, bias
    ; generator, and output
    ; buffer
    mov AMX0SL, #0fh ; select TEMP sensor as ADC0
    ; input
    mov ADC0CF, #80h ; set SAR clock to SYSCLK/16
    orl ADC0CF, #01h ; PGA Gain = 2
    mov ADC0CN, #45h ; ADC disabled, low power
    ; track mode, ADC0 conversions
    ; initiated by overflow on
    ; Timer3, left-justified data
    ret
    ;
    ; This routine enables the ADC and ADC interrupts.
    ADC0_Enable:
    setb ADCEN ; enable ADC
    orl EIE2, #02h ; enable ADC EOC interrupt
    ret;
    ; End of file.
    END

Children
No data