Microcontroller › 8051 › 8051 problem asm code. unfinished temperature sensor, need help please.
- This topic has 2 replies, 3 voices, and was last updated 11 years, 6 months ago by umar farrok.
-
AuthorPosts
-
February 26, 2013 at 2:21 pm #4800bobParticipanthi 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 advancecurrent embedded image.current code:$mod51rw equ P3.1rs equ P3.0en equ P3.2org 0000hclr rwacall lcd_initmain:mov a, #’W’acall lcd_datamov a,#’e’acall lcd_datamov a, #’l’acall lcd_datamov a,#’c’acall lcd_datamov a, #’o’acall lcd_datamov a,#’m’acall lcd_datamov a, #’e’acall lcd_datamov a,#’ ‘acall lcd_datamov a,#’K’acall lcd_datamov a,#’e’acall lcd_datamov a,#’i’acall lcd_datamov a,#’t’acall lcd_datamov a,#’h’acall lcd_datasjmp $lcd_init:mov a,#01hacall lcd_cmdmov a,#38hacall lcd_cmdmov a,#0chacall lcd_cmdmov a,#06hacall lcd_cmdretlcd_cmd:clr rsmov p2,asetb enacall delayclr enretlcd_data:setb rsmov p2,asetb enacall delayclr enretdelay:mov r0,#5hl2: mov r1,#0ffhl1: djnz r1,l1djnz r0,l2retend]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]its an 8051 micro controller. at89c51for adc communication I think it will be something along the lines of this, correct me if im wrongrd equ P1.0 ;Read signal P1.0wr equ P1.1 ;Write signal P1.1cs equ P1.2 ;Chip Select P1.2intr equ P1.3 ;INTR signal P1.3adc_port equ P2 ;ADC data pins P2adc_val equ 30H ;ADC read value stored hereorg 0Hstart: ;Start of Programacall conv ;Start ADC conversionacall read ;Read converted valuemov P3,adc_val ;Move the value to Port 3sjmp start ;Do it againconv: ;Start of Conversionclr cs ;Make CS lowclr wr ;Make WR Lownopsetb wr ;Make WR Highsetb cs ;Make CS highwait:jb intr,wait ;Wait for INTR signalret ;Conversion doneread: ;Read ADC valueclr cs ;Make CS Lowclr rd ;Make RD Lowmov a,adc_port ;Read the converted valuemov adc_val,a ;Store it in local variablesetb rd ;Make RD Highsetb cs ;Make CS Highret ;Reading done]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]the temperature will range from using the voltage formulaso 1v=100 degrees Celsius.50v= 50 degrees Celciusit is to be displayed in CelciusMarch 2, 2013 at 4:14 pm #9219preethiParticipant
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.1cs equ P3.2 ;Chip Select P3.2intr equ P3.3 ;INTR signal P3.3adc_port equ P1 ;ADC data pins P1March 4, 2013 at 10:51 am #9237umar farrokParticipantyou 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
-
AuthorPosts
- You must be logged in to reply to this topic.