| |
webled.pwp
//-------------------------------------------------------------------------
//
// PicoWeb Project File for WebLED
//
//-------------------------------------------------------------------------
//
// application-specific preprocessor definitions
//
#define BANNER "\r\nPicoWeb WebLED\r\n"
#define EEPROM_IP /* use file "ip" for IP address */
#define ENABLE_WATCHDOG /* use Atmel watchdog timer hardware */
#define DEBUGGER /* include debugger firmware */
#define SERIAL_BAUD_DIVISOR 25 /* serial port speed: 19200 baud @ 8 MHz */
#define DS1621_BASE_ADDR 0x9E /* ext. DS1621 digital thermometer */
#define I2C_PORT1_PRESENT /* enable I2C code for DS1621 */
//
// application-specific HTML and image file names
//
webled.htm // ii00 (default Web page)
bruce.jpg // ii01
dave.jpg // ii02
steve.jpg // ii03
//
// application-specific CGI routines
//
temperature.cgi // iu00 (returns ASCII temperature reading (deg-f)
//
// application-specific assmbly language files
//
//mycode.asm
//
// included application-specific pcode and/or AVR assembly language follows
//
#avr_reset
;--------------------------------------------------------------------------
; this code is executed each time microcontroller is reset
;--------------------------------------------------------------------------
;
sbi ddrd,LED_BIT ; make LED driver pin an output
ldi yl,0xEE ; start DS1621 temperature conversion
rcall ds1621_write
#avr_slow
;--------------------------------------------------------------------------
; this code is executed each trip through "slow idle" loop (~1 sec period)
;--------------------------------------------------------------------------
;
#avr_fast
;--------------------------------------------------------------------------
; this code is executed each trip through "fast idle" loop
;--------------------------------------------------------------------------
;
#avr_asm
;--------------------------------------------------------------------------
; application-specific CGI pcode and AVR assembly routines go here
;--------------------------------------------------------------------------
;
;--------------------------------------------------------------------------
;+
; **-temperature-show the temperature (deg-F) in decimal.
;-
;--------------------------------------------------------------------------
.eseg
temperature:
pcall tempf_buf ; read temp in deg-F
pcall decconv ; convert to decimal ascii
pret
;--------------------------------------------------------------------------
;+
; **-tempf_buf-read temp (deg-C) from DS1621 and convert to deg-F
;
; inputs:
; none
;
; outputs:
; buf = latest temperature reading in degrees Fahrenheit
;-
;--------------------------------------------------------------------------
.cseg
tempf_buf:
pclrw buf
pread_temp buf ; get temp
pmovwi buf+4,0x80 ; set up for sign test
pandwi buf+4,[buf] ; check the sign
pjumpeq temp_positive ; it is positive
pmovbi buf+1,0xff ; extend the sign
pnegw buf ; negate
temp_positive:
pmul buf,[buf],9 ; C*9
pdiv buf,[buf],5 ; /5
pandwi buf+4,0x80 ; test original sign
pjumpeq temp_norenegate ; positive
pnegw buf
temp_norenegate:
paddwi buf,32 ; +32 - buf now has temp (F)
pret
;--------------------------------------------------------------------------
;+
; **-decconv-decimal converter.
;
; inputs:
; buf = word to convert
;
; outputs:
; result printed (with pputc)
;-
;--------------------------------------------------------------------------
#define DIG_BUF buf+6
#define DIG_PTR buf+4
#define DEC_REM buf+2
#define DEC_VAL buf
.cseg
decconv:
pmovwi DIG_PTR,DIG_BUF ; get input word
pbitwi DEC_VAL,0x8000 ; check the sign
pjumpeq decconv1 ; positive - start conversion
pnegw DEC_VAL ; negate it
pputc '-'
decconv1:
pdiv DEC_VAL,[DEC_VAL],10 ; get next one
paddwi DEC_REM,'0' ; convert digit for display
pmovbi [DIG_PTR],[byte DEC_REM] ; save digit
paddwi DIG_PTR,1 ; bump past digit just stored
psubwi DEC_VAL,0 ; test remaining value
pjumpne decconv1 ; if more to convert
decconv2:
psubwi DIG_PTR,1 ; point to next one
pputcb [byte DIG_PTR] ; show it
pcmpwi DIG_PTR,DIG_BUF ; check if just did last one
pjumpne decconv2 ; nope - do next one
pret
;--------------------------------------------------------------------------
.cseg
#include "muldiv.asm"
Back
|
|
|