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
  • ; Temp_2.ASM
    ; This program configures the on-chip temperature sensor with the ADC.
    ; An external 18.432MHz crystal is used as the system clock source.
    ; The ADC is configured for left-justified mode, GAIN = 2, using Timer3 overflows
    ; as the start-of-conversion source.
    ; Timer3 is configured in auto-reload mode to overflow every 10ms.
    ; The ADC conversion complete interrupt handler reads the ADC value and compares it
    ; Tmp = (about 25 degrees C), stored in ROOMCODE.
    ; If the measured Tmp is below this value, the LED is turned off.
    ; If the measured value is above ROOMCODE, the LED is turned on.
    ; The LED switch point value - ROOMCODE.
    ;
    ; EQUATES
    $INCLUDE (C8051F000.inc)
    LED EQU P1.6 ;LED on target board ('1' is LED ON)
    SYSCLK EQU 18432 ;SYSCLK frequency in kHz
    TC_10ms EQU (SYSCLK / 12) * 10 ;number of timer counts in 10ms
    ROOMCODE EQU 0xb3f0 ;left-justified ADC value for 25 degrees C.
    ;
    ; VARIABLES
    ;
    MYDATA SEGMENT DATA ; declare DATA segment
    RSEG MYDATA ; select DATA segment
    ; ADC data variables
    TEMPCODE: DS 2 ; holding register for temp code (16-bit)
    ; stored MSB-first
    ;
    ; STACK

    STACK SEGMENT IDATA ; declare STACK segment
    RSEG STACK
    DS 80h ; reserve 128 bytes for stack
    ;
    ; MACRO DEFINITIONS
    ; RESET AND INTERRUPT VECTOR TABLE
    ;
    CSEG AT 0
    ljmp Main
    org 7bh
    ljmp ADC0_ISR ; ADC0 end of conversion interrupt

Reply
  • ; Temp_2.ASM
    ; This program configures the on-chip temperature sensor with the ADC.
    ; An external 18.432MHz crystal is used as the system clock source.
    ; The ADC is configured for left-justified mode, GAIN = 2, using Timer3 overflows
    ; as the start-of-conversion source.
    ; Timer3 is configured in auto-reload mode to overflow every 10ms.
    ; The ADC conversion complete interrupt handler reads the ADC value and compares it
    ; Tmp = (about 25 degrees C), stored in ROOMCODE.
    ; If the measured Tmp is below this value, the LED is turned off.
    ; If the measured value is above ROOMCODE, the LED is turned on.
    ; The LED switch point value - ROOMCODE.
    ;
    ; EQUATES
    $INCLUDE (C8051F000.inc)
    LED EQU P1.6 ;LED on target board ('1' is LED ON)
    SYSCLK EQU 18432 ;SYSCLK frequency in kHz
    TC_10ms EQU (SYSCLK / 12) * 10 ;number of timer counts in 10ms
    ROOMCODE EQU 0xb3f0 ;left-justified ADC value for 25 degrees C.
    ;
    ; VARIABLES
    ;
    MYDATA SEGMENT DATA ; declare DATA segment
    RSEG MYDATA ; select DATA segment
    ; ADC data variables
    TEMPCODE: DS 2 ; holding register for temp code (16-bit)
    ; stored MSB-first
    ;
    ; STACK

    STACK SEGMENT IDATA ; declare STACK segment
    RSEG STACK
    DS 80h ; reserve 128 bytes for stack
    ;
    ; MACRO DEFINITIONS
    ; RESET AND INTERRUPT VECTOR TABLE
    ;
    CSEG AT 0
    ljmp Main
    org 7bh
    ljmp ADC0_ISR ; ADC0 end of conversion interrupt

Children
No data