clock.pwp


//-------------------------------------------------------------------------
//
// PicoWeb Project File for CLOCK
//
//-------------------------------------------------------------------------
//
// application-specific preprocessor definitions
//
#define BANNER "\r\nPicoWeb Java Clock\r\n"
#define EEPROM_IP         /* use file "ip" for IP address */
#define NET_CONFIG_IP     /* allow IP address reconfiguration via net */
#define ENABLE_WATCHDOG   /* use Atmel watchdog timer hardware */
#define DEBUGGER          /* include debugger firmware */

//#define CLOCK 8000000
#define CLOCK 7372000     /* processor clock rate (Hz) */
#define BAUD_RATE 19200   /* serial port baud rate */

link add i2cprog_I2C_PORT1_PRESENT.o  // use special version of I2C routine

//
// application-specific HTML and image file names
//
clock.htm       // (default Web page)
clock.class     // (Java Applet)
temp.htm        // (returns HTML page with ACSII temp reading)

//
// application-specific CGI routines
//
temperature.cgi // (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
    pprintswi [buf]                    ; output as 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


Back