93c46 yazma ve okuma

Başlatan setas, 16 Mayıs 2003, 13:28:39

setas

93c46  seri  eeproma  8 bit (org=vss)yazma  ve  okuma rutinleri  lazım.yardımcı olabilirmisiniz  teşekkürler.

byka

DWIN LCD Satış Türkiye email:info@kamantek.com  web:http://www.kamantek.com/shop/index.php

setas

appnotlara bakmıstım zaten. 8bit acık kodları moduler buraya yazabilirmisiniz. teşekkürler

zorbey

93c46 için kaynak kod
;=======93C46.
       list    p=16c84
       radix  

hex
;------------------------------------------------------------
;       cpu equates (memory map)
status   equ   0x03
porta   equ   0x05
portb   equ    

0x06
cook   equ   0x0c
hibyte   equ   0x0d
count   equ   0x0e
address   equ   0x0f
data_hi   equ   0x10
data_lo   equ   0x11
temp   equ   0x12
trisa   equ   

0x85
trisb   equ   0x86
;------------------------------------------------------------
;   bit equates
rp0   equ   5
;------------------------------------------------------------
       org    

0x000
;
start   bsf     status,rp0  ;switch to bank 1
   movlw   b'00000001' ;bit 0 = input
       movwf   trisa
   movlw   b'00000000'

;outputs
   movwf   trisb
   bcf   status,rp0  ;switch back to bank

0
   bcf   porta,1   ;initialize
   bcf   porta,2   ;initialize
   bcf   porta,3   ;initialize
   movlw   0x00   ;00000000
   movwf   portb   ;LEDs off
   movlw   0x00   ;define

test address
   movwf   address
   movlw   0x80   ;define test hi byte
   movwf   data_hi
   movlw   0x0f   ;define   test lo byte
   movwf   data_lo
   call   write   ;write

subroutine
   call   read   ;read subroutine
   movf   cook,w   ;get lo byte
   movwf   portb   ;display via LEDs
circle  goto    circle  

;done
;------------------------------------------------------------
ewen   movlw   0x30   ;ewen op code
   movwf   cook   ;to cook
   bsf   porta,1   ;send start

bit
   bsf   porta,2   ;shift
   bcf   porta,2
   call   sendbits    ;send ewen op code
   return
;------------------------------------------------------------
ewds   movlw   0x00   ;ewds

op code
   movwf   cook   ;to cook
   bsf   porta,1   ;send start bit
   bsf   porta,2   ;shift
   bcf   porta,2
   call   sendbits    ;send ewds op

code
   return
;------------------------------------------------------------   
write   bsf   porta,3   ;cs high
   call   ewen   ;erase/write enable
   bcf   porta,3   ;cs low
   nop      ;1

microsecond min
   bsf   porta,3   ;cs high
   movf   address,w   ;get address
   movwf   cook   ;store in cook
   bcf   cook,7   ;op code
   bsf   cook,6   ;ms 2

bits
   bsf   porta,1   ;send start bit
   bsf   porta,2   ;shift
   bcf   porta,2
   call   sendbits    ;send address
   movf   data_hi,w   ;get data

hi
   movwf   cook
   call   sendbits    ;send data hi
   movf   data_lo,w   ;get data lo
   movwf   cook
   call   sendbits    ;send data lo
   bcf   porta,3   ;cs

low
   nop      ;1 microsecond min
   bsf   porta,3   ;cs high
ecycle2   btfss   porta,0   ;erase cycle complete?
   goto   ecycle2   ;not yet
   bcf   porta,3   ;cs

low
   nop      ;1 microsecond min
   call   ewds   ;yes, erase/write disable
   bcf   porta,3   ;cs low
   nop      ;1 microsecond

min
   return
;------------------------------------------------------------
read   bsf   porta,3 ;cs high
   movf   address,w   ;get address
   movwf   cook
   bsf   cook,7   ;op

code
   bcf   cook,6  ;ms 2 bits
   bsf   porta,1   ;send start bit
   bsf   porta,2   ;shift
   bcf   porta,2
   call   sendbits    ;send address
   call   getprom     ;shift hi 8 bits

out of eeprom
   movf   cook,w   ;hi byte result in hibyte
   movwf   hibyte
   call   getprom     ;shift lo 8 bits out of eeprom
   bcf   porta,3   ;cs low
   nop      ;1microsecond

min
   return      ;exit sub with lo byte in cook
;------------------------------------------------------------
sendbits

movlw   0x08   ;count=8
   movwf   count
sbit   call   sendbit   ;send 1 bit
   decfsz  count,f   ;done?
   goto   sftcook ;no
   return      ;yes
sftcook   rlf   cook,f   ;shift

cook left
   goto   sbit   ;again
;------------------------------------------------------------
sendbit   bcf   porta,1   ;default
   btfsc   cook,7   ;test cook bit 7
   bsf   porta,1 ;bit is

set
shift1   bsf   porta,2   ;shift
   bcf   porta,2
   return
;------------------------------------------------------------
getprom   movlw   0x08   ;count=8
   movwf   count
shif

t2   bsf   porta,2   ;shift
   bcf   porta,2
   movf   porta,w ;read port A
   movwf   temp   ;store copy
   rrf   temp,f   ;rotate bit into carry flag
   rlf   cook,f   ;rotate carry flag

into cook
   decfsz   count,f   ;decrement counter
   goto   shift2
   return      ;done
;------------------------------------------------------------
       

end
;------------------------------------------------------------
;at blast time, select:
;       memory unprotected
;       watchdog timer disabled (default is enabled)
;       standard crystal

(using 4 MHz osc for test) XT
;       power-up timer

on
;============================================================


;------------------------------------------------------------
erase   bsf   porta,3   ;c

s high
   call   ewen   ;erase/write enable
   bcf   porta,3   ;cs low
   nop      ;1 microsecond min
   bsf   porta,3   ;cs high
   movf   address,w   ;get

address
   movwf   cook   ;store in cook
   bsf   cook,7   ;op code
   bsf   cook,6   ;ms 2 bits
   bsf   porta,1   ;send start

bit
   bsf   porta,2   ;shift
   bcf   porta,2
   call   sendbits    ;send address
   bcf   porta,3   ;cs low
   nop      ;1 microsecond min
   bsf   porta,3   ;cs

high
ecycle1   btfss   porta,0   ;erase cycle complete?
   goto   ecycle1   ;not yet
   bcf   porta,3   ;cs low
   nop      ;1microsecond min
   call   ewds   ;yes, erase/write

disable
   bcf   porta,3   ;cs low
   nop      ;1microsecond min
   return