Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/07/04 18:45
Read: times


 
#68101 - LM75
I have been trying to communicate with a LM75, Read the datasheets pondered over, and made this assembly language prg, but it doesn't work, could sombody help me please , what am i doing wrong
i am using paulmon as monitor.
#include 8051.H


locat .equ 2000H ;Location for this program

.org locat

.db $A5,$E5,$E0,$A5 ;signiture bytes
.db 35,255,0,0 ;id (35=prog, 249=init, 253=startup, 254=cmd)
.db 0,0,0,0 ;prompt code vector
.db 0,0,0,0 ;reserved
.db 0,0,0,0 ;reserved
.db 0,0,0,0 ;reserved
.db 0,0,0,0 ;user defined
.db 255,255,255,255 ;length and checksum (255=unused)
.db "SPI OUTPUT",0

.org locat+64 ;executable code begins here


cout .equ 0030H
cin .equ 0032H
phex .equ 0034H
phex16 .equ 0036H
pstr .equ 0038H
newline .equ 0048H

stack .equ 20H
MOSI .equ P1.1
SCK .equ P1.2




main:

on_reset:
mov SP, #(stack-1) ; initialize stack pointer

clr P1.4 ;Led off
setb MISO ; high
setb MOSI ; high
setb SCK ; low

;mov a, #10
;acall delay_ms

mov r0,#255
mov r1,#255


mov a,#91H ; Enable read signature
acall shout

jc error
loop acall shin
mov r0,a
acall shin
mov r1,a
mov a,#'A'
lcall cout
mov a,#'B'
lcall cout
sjmp $


error mov dptr,#mesg
lcall pstr
sjmp $

mesg .db " Temp ",0


shout:

; Shift out a byte, most significant bit first.
; SCK expected low on entry. Return with SCK low.
; Called with data to send in A.
; Returns nothing.
; Destroys A.

push b
mov b, #8 ; bit counter
clr MOSI
clr SCK
nop
nop
nop
x42: setb SCK
rlc a ; move bit into CY 1
mov MOSI, c ; output bit 2
nop ; enforce data setup 1
nop ; 1
clr SCK ; raise clock 1
nop ; enforce SCK high 1
nop ; 1
nop ; 1
nop ; 1
djnz b, x42 ; next bit 2
pop b

clr c
setb MOSI
setb SCK
nop
nop
mov c,MOSI
nop
nop
clr SCK
ret


shin:

; Shift in a byte, most significant bit first.
; SCK expected low on entry. Return with SCK low.
; Returns received data byte in A.

push b
mov b, #8 ; bit counter
x43:
setb SCK ; raise clock 1
mov c, MISO ; input bit 1
rlc a ; move bit into byte 1
nop ; enforce SCK high 1
nop ; 1
clr SCK ; drop clock 1
nop ; enforce SCK low 1
nop ; 1
djnz b, x43 ; next bit 2

pop b
ret


delay_ms:

; Delay for one mS times the value in the accumulator.

push acc
push b

mov b, #0
dd:
djnz b, $ ; 500 uS @ 12 MHz
djnz b, $ ; 500 uS @ 12 MHz
djnz acc, dd

pop b
pop acc
ret

.end




List of 26 messages in thread
TopicAuthorDate
LM75            01/01/70 00:00      
   RE: LM75 ???            01/01/70 00:00      
      RE: LM75 ???            01/01/70 00:00      
   RE: LM75            01/01/70 00:00      
      RE: LM75            01/01/70 00:00      
      RE: LM75            01/01/70 00:00      
         Dont do what I say; do what I MEAN!            01/01/70 00:00      
            RE: Dont do what I say; do what I MEAN!            01/01/70 00:00      
               RE: Dont do what I say; do what I MEAN!            01/01/70 00:00      
                  RE: Dont do what I say; do what I MEAN!            01/01/70 00:00      
                  RE: Datasheets            01/01/70 00:00      
                  RE: Dont do what I say; do what I MEAN!            01/01/70 00:00      
                     RE: Dont do what I say; do what I MEAN!            01/01/70 00:00      
   RE: LM75            01/01/70 00:00      
      I2C, not SPI.            01/01/70 00:00      
         I2C or SPI or XYZ - Thanks anyway!            01/01/70 00:00      
            RE: I2C or SPI or XYZ - Thanks anyway!            01/01/70 00:00      
               RE: I2C or SPI or XYZ - Andy            01/01/70 00:00      
      RE: LM75            01/01/70 00:00      
         RE: LM75            01/01/70 00:00      
            it is i2c as far as i could do            01/01/70 00:00      
               RE: it is i2c as far as i could do            01/01/70 00:00      
               RE: it is i2c as far as i could do            01/01/70 00:00      
                  RE: it is i2c as far as i could do            01/01/70 00:00      
   a general recommendation            01/01/70 00:00      
   RE: LM75            01/01/70 00:00      

Back to Subject List