sht11 source code
Hi, thanks for the reply.
The trouble is, I have to do it in assembly code, using the AVR Studio 3.56. So far I have my 2x16 display outputting a user defined sentence, in my case, I've put in "Roll on Easter, 11 weeks to go"
My code so far is:
--------------------------
.include "m8def.inc"
.def temp =r16
.def disp =r17
.equ width =$00dd
;********************************************************
.equ LCD_O =portd ;Output to LCD
.equ LCD_I =pinb ;Input from LCD
.equ CTRL_O =portc ;Control output
.equ E =2 ;Active high enable
.equ DC =0 ;Data/Command
.equ BF =7 ;Busy Flag
.equ FS =$3f ;Function set
.equ DISP_ON =$0c ;Display on w/o blink or flash
.equ DISP_OFF =$08 ;Display, blink, cursor off
.equ DISP_CL =$01 ;Clear display
.equ DISP_EN =$06 ;Data entry mode
.equ LINE_1 =$80 ;DDRAM address for first line
.equ LINE_2 =$c0 ;DDRAM address for second line
.equ SH_LFT =$18 ;Left-shift display
.equ SH_RT =$1c ;Right-shift display
.equ HOME =$02 ;Return home
;********************************************************
reset: ldi temp, low(ramend)
out SPL, temp
ldi temp, high(ramend)
out SPH, temp
ser temp
out DDRB, temp
out DDRC, temp
out DDRD, temp
;rjmp pwm
rcall lcd_en
rcall del
rcall del
rcall del
rcall del
rcall del
ldi zl, low(Steve*2)
ldi zh, high(Steve*2)
loop2: lpm disp, z+
cpi disp, $ff
breq label
rcall wrt_d
rcall del
rjmp loop2
label: ldi disp, Line_2
rcall wrt_c
ldi zl, low(date*2)
ldi zh, high(date*2)
loop: lpm disp, z+
cpi disp, $ff
breq pwm
rcall wrt_d
rcall del
rjmp loop
;*********************************
pwm: ldi temp, $a1
out TCCR1A, temp
ldi temp, high(width)
out OCR1AH, temp
out OCR1BH, temp
ldi temp, low(width)
out OCR1AL, temp
out OCR1BL, temp
ldi temp, $01
out TCCR1B, temp
here: rjmp here
;********************************************************
;Set up lcd
LCD_EN: rcall del
rcall del
rcall del
rcall del
ldi disp, FS
rcall wrt_c
rcall wrt_c
rcall wrt_c
rcall wrt_c
rcall del
rcall del
ldi disp, DISP_ON
rcall wrt_c
ldi disp, DISP_EN
rcall wrt_c
ldi disp, DISP_CL
rcall wrt_c
rcall del
rcall del
ret
;********************************************************
;********************************************************
;Writes the command in the 'disp' register to the LCD.
wrt_c: rcall del
cbi CTRL_O, DC
sbi CTRL_O, E
out LCD_O, disp
cbi CTRL_O, E
ret
;********************************************************
;Writes data in the 'disp' register to the LCD.
wrt_d: rcall del
sbi CTRL_O, DC
sbi CTRL_O, E
out LCD_O, disp
cbi CTRL_O, E
ret
;********************************************************
;********************************************************
;64us delay using 8-bit timer
del: push temp
ldi temp, $df
out TCNT0, temp
ldi temp, $02
out TCCR0, temp
dloop: in temp, TIFR
andi temp, $01
cpi temp, $01
breq cflg
cpi temp, $08
brne dloop
cflg: ldi temp, $01
out TIFR, temp
clr temp
out TCCR0, temp
pop temp
ret
;********************************************************
Steve: .db "ROLL ON EASTER--",$ff,$ff
date: .db "11 WEEKS TO GO!!",$ff
------------------
The PWM is to control power resistors which I am using as a heater. The code you pointed me in the direction os great, but its in BASIC. I have to do it in assembly language. Can that code be converted to Assembly? If so, how?
Can you help me please? I don't have a clue! By the way, this code is not mine, it was given to me by someone - please dont think I can program :0).
Anyway, I hope you can help.
Many thanks,
Steve (captaingrice@blueyonder.co.uk)