EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / 8051 problem asm code. unfinished temperature sensor, need help please.

8051 problem asm code. unfinished temperature sensor, need help please.

|

Microcontroller › 8051 › 8051 problem asm code. unfinished temperature sensor, need help please.

  • This topic has 2 replies, 3 voices, and was last updated 12 years, 9 months ago by umar farrok.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 26, 2013 at 2:21 pm #4800
    bob
    Participant

     

    hi wondering if anyone can help me out with this, ive got the lcd displaying information, but i want it to display the temperature using the lm35 and adc0804 as well, using asm code. Basically i need to get the current reading from the lm35 and convert them in the adc0804 and then display that reading in degrees on the lcd display. I have found some similar projects like this but they were written in C. any help needed, thanks in advance
     
    current embedded image
     

    .
     
    current code:
     
    [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
     
    $mod51
    rw equ P3.1
    rs equ P3.0
    en equ P3.2
     
    org 0000h
     
    clr rw
    acall lcd_init
    main:
    mov a, #’W’
    acall lcd_data
    mov a,#’e’
    acall lcd_data
    mov a, #’l’
    acall lcd_data
    mov a,#’c’
    acall lcd_data
    mov a, #’o’
    acall lcd_data
    mov a,#’m’
    acall lcd_data
    mov a, #’e’
    acall lcd_data
    mov a,#’ ‘
    acall lcd_data
    mov a,#’K’
    acall lcd_data
    mov a,#’e’
    acall lcd_data
    mov a,#’i’
    acall lcd_data
    mov a,#’t’
    acall lcd_data
    mov a,#’h’
    acall lcd_data
    sjmp $
     
     
    lcd_init:
    mov a,#01h
    acall lcd_cmd
    mov a,#38h
    acall lcd_cmd
    mov a,#0ch
    acall lcd_cmd
    mov a,#06h
    acall lcd_cmd
    ret
     
     
    lcd_cmd:
    clr rs
    mov p2,a
    setb en
    acall delay
    clr en
    ret
     
    lcd_data:
    setb rs
    mov p2,a
    setb en
    acall delay
    clr en
    ret
     
    delay:
    mov r0,#5h
    l2: mov r1,#0ffh
    l1: djnz r1,l1
        djnz r0,l2
    ret
     
    end
     
    ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
     
    its an 8051 micro controller. at89c51
    for adc communication I think it will be something along the lines of this, correct me if im wrong
     
    [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
     
    rd equ P1.0 ;Read signal P1.0
    wr equ P1.1 ;Write signal P1.1
    cs equ P1.2 ;Chip Select P1.2
    intr equ P1.3 ;INTR signal P1.3
     
    adc_port equ P2 ;ADC data pins P2
    adc_val equ 30H ;ADC read value stored here
     
    org 0H
    start: ;Start of Program
    acall conv ;Start ADC conversion
    acall read ;Read converted value
    mov P3,adc_val ;Move the value to Port 3
    sjmp start ;Do it again
     
    conv: ;Start of Conversion
    clr cs ;Make CS low
    clr wr ;Make WR Low
    nop
    setb wr ;Make WR High
    setb cs ;Make CS high
    wait:
    jb intr,wait ;Wait for INTR signal
    ret ;Conversion done
     
    read: ;Read ADC value
    clr cs ;Make CS Low
    clr rd ;Make RD Low
    mov a,adc_port ;Read the converted value
    mov adc_val,a ;Store it in local variable
    setb rd ;Make RD High
    setb cs ;Make CS High
    ret ;Reading done
     
    ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
     
    the temperature will range from using the voltage formula 
    so 1v=100 degrees Celsius 
    .50v= 50 degrees Celcius
     
    it is to be displayed in Celcius
    March 2, 2013 at 4:14 pm #9219
    preethi
    Participant

    hi bob……..in your circuit you have connected adc0804 data pins to microcontroller port1 that means p1.0 to p1.7….But in your program you have given it to microcontroller port2 that means p2

    and also

    As per your circuit you have connected rd, wr, cs, intr pins of adc0804 to port 3……. but in the program it is declared as port1

    So, make changes in  your code for adc0804 to connect data pins of adc0804 to port1 and control pins rd, wr, cs, intr to port3 of microcontroller

    correct lines as per your circuit  are 

     

                   rd equ P3.0 ;Read signal P3.0

                   wr equ P3.1 ;Write signal P3.1
                   cs equ P3.2 ;Chip Select P3.2
                   intr equ P3.3 ;INTR signal P3.3
     
                   adc_port equ P1 ;ADC data pins P1
    March 4, 2013 at 10:51 am #9237
    umar farrok
    Participant

    you no need to assign for chip select by default it is high only , you only need to assign for adc is data 8 pins be sure the pins you connect in the circuit  either from 0 to 8 or 8 to 0 th bit arrangement, three pin for control pin of adc rd,  wr,  intr……. totally you need tow ports one for data and another for control

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • What is involved to convert a small town to fiber optic? December 11, 2025
  • volkswagen car stereo model rcd310 December 11, 2025
  • Dog fence help December 11, 2025
  • anyone recognizes this laser diode? December 10, 2025
  • How to power motors for lumbar support? December 10, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise