电路设计,软件开发,专业项目团队承接电子产品开发!


ISPRO下载型编程器
火爆销售中

RS232/TTL转换器
全IC串口窃电

RS232/TTL转换线
全IC串口窃电

ByteBlasterMV Cable
CPLD/FPGA并口下载线

ByteBlaster II Cable ISPRO下载型编程器
支持S51/AVR/PIC
超级51开发板套件
前卫实用超值

PC/MCU/CPLD
三合一学习套件

全新万年历方案
AVR单片机开发板
 

Min51单片机仿真机
迷你型

ARM7开发板
仅售260元!
 

RS-232/RS-485双向接口电平转换器  

51单片机升级STM32
火爆销售中
MPLAB-ICD2
火爆销售中
LED51开发板
玩具又名图文显示棒

面板模块/开发板
经济危机明智决择

       

GSM MODEM GSM猫

SMS短信模块 工业级/全自动
火爆销售中

大功率数传电台

高速数传电台

您当前位置:电子技术资料 -> 外围驱动 -> EEPROM ->

祝您阅读愉快!

ISPRO下载型编程器

RS232 TO TTL转换器
↑↑本文相关产品介绍↑↑

以前用的93C46汇编程序


类别:技术文章
来源:未知
作者:未知
关键字:at93C46
加入日期:2010-8-3

; Assembler: X8051 v4.03a 2500 A.D.
;中国电子网 www.EC66.com
; 93C46
EEPROM_CS reg p2.0 ; CS
EEPROM_SK reg p2.1 ; SK
EEPROM_DI reg p2.2 ; DI
EEPROM_DO reg p2.3 ; DO

TestEEPROMRoutine:
call FinishEEPROM ; Power ON first time for
93C46
;
call WriteEEPROMEnable
mov r0, #00h
mov a, #55h
call WriteEEPROM
call WriteEEPROMDisable
;
mov r0, #00h
call ReadEEPROM
xrl a, #55h ; ZF = 1 Success
ret

;*****************************************************************************;
; EEPROM SubRoutine ;
;*****************************************************************************;
PrepareEEPROMCmd:
clr EEPROM_DI
clr EEPROM_SK ; SK, DI low
nop
clr EEPROM_CS
call EDelay
;
setb EEPROM_DO ; set DO input
nop
setb EEPROM_CS ; CS active
nop
nop
setb EEPROM_DI ; DI high
nop
setb EEPROM_SK ; SK high (Latch start bit)
nop
nop
clr EEPROM_SK ; SK low
nop
ret

FinishEEPROMCmd:
clr EEPROM_DI
clr EEPROM_SK ; SK, DI low
nop
clr EEPROM_CS ; CS low
call EDelay
ret

OutputEEPROMData:
mov c, a.7
rl a
mov EEPROM_DI, c ; DI = data
nop
setb EEPROM_SK ; SK high
nop
nop
clr EEPROM_SK ; SK low
nop
djnz r2, OutputEEPROMData
ret

WriteEEPROMEnable:
call PrepareEEPROMCmd
mov a, #00000000b ; 00 Write Enable
mov r2, #2
call OutputEEPROMData
mov a, #11000000b ; 11xxxx Write Enable Address
mov r2, #6
call OutputEEPROMData
call FinishEEPROMCmd
ret

WriteEEPROMDisable:
call PrepareEEPROMCmd
mov a, #00000000b ; 00 Write Disable
mov r2, #2
call OutputEEPROMData
mov a, #00000000b ; 00xxxx Write Disable Address
mov r2, #6
call OutputEEPROMData
call FinishEEPROMCmd
ret

InputEEPROMData:
clr a
InputEEPROMData_Loop:
setb EEPROM_SK ; SK high
nop
nop
mov c, EEPROM_DO ; data = DO
clr EEPROM_SK ; SK low
nop
rlc a
djnz r2, InputEEPROMData_Loop
ret

ReadEEPROM:
call PrepareEEPROMCmd
mov a, #10000000b ; 10 Read Command
mov r2, #2
call OutputEEPROMData
mov a, r0 ; Address
anl a, #3Fh
rl a
rl a
mov r2, #6
call OutputEEPROMData
clr EEPROM_DI ; DI low before Read Data
mov r2, #8 ; Read High byte
call InputEEPROMData
mov b, a
mov r2, #8
call InputEEPROMData ; Read Low byte
call FinishEEPROMCmd
ret

WriteEEPROM:
call PrepareEEPROMCmd
push a
mov a, #01000000b ; 01 Write Command
mov r2, #2
call OutputEEPROMData
mov a, r0 ; Address
anl a, #3Fh
rl a
rl a
mov r2, #6
call OutputEEPROMData
mov a, b
mov r2, #8
call OutputEEPROMData ; Write High byte
pop a
mov r2, #8
call OutputEEPROMData ; Write Low byte
clr EEPROM_CS ; CS low
call EWDelay ; about 20 ms
call FinishEEPROMCmd
ret

; base on 11.0592 MHz
EDelay:
mov r7, #23 ; 1 + 23 * 2 = 47 clocks / 921600 = 50
us
djnz r7, $
ret

EWDelay: ; about 20 ms
mov r6, #20
EWDelay_Main: ; about 1 ms (1025 clocks / 921600 =
1.1121 ms)
mov r7, #230 ; 1 + 230 * (1 + 1 + 2) = 921 clocks /
921600 = 0.999 ms
EWDelay_Sub:
nop
nop
djnz r7, EWDelay_Sub
djnz r6, EWDelay_Main ; 2 clocks
ret

您可能还会关注的相关技术资料:

中国电子网
www.EC66.com
QQ:34740080 EMAIL:iloveaoe@163.com
最佳浏览:1024*768
Copyright (C) 2001-2010 EC66.COM All Rights Reserved
Aoe/帝国 制作维护
粤ICP备18061901号