at89s51+93C56

Software e Hardware para linha x51

Moderadores: 51, guest2003, Renie, gpenga

at89s51+93C56

Mensagempor batpoa » 07 Nov 2010 18:44

Olá pessoal do forun gostaria de saber se alguem teria alguma rotina de leitura e escrita de eeprom 93c56 em assembler para os microcontroladores da linha 8051 pois preciso fazer um programa que utilize uma eeprom 93c56, desde já agradeço.
batpoa
Bit
 
Mensagens: 6
Registrado em: 24 Jan 2009 20:51

Mensagempor tcpipchip » 08 Nov 2010 08:33

Acredito que voce queira por BIT BANG, certo ?
As rotinas abaixo implementam SPI...

Código: Selecionar todos
Program: LTC 1098 bit-bang ______
;-------------------------------------------------
;Program: MODspi.ASM
;Update: 01 March, 2003
;Initial: May 23, 1994 @ Foxfire, MO
;By: Dr. Marcus O. Durham, PhD, PE
; Tulsa, OK, USA
; mod@superb.org
; www.ThewayCorp.com
;Copyright (c)1994, 2003. All rights reserved
;
;Purpose:
; A set of routines are provided to read from
; a serial peripheral interface. The device is
; a 12-bit analog to digital converter.
;
;Processor: 8031 family
276 Systems Design and the 8051 Durham
;PROM: 8k (2000H) onboard
;Crystal: 11.059 MHz
;Assembler: Intel ASM51
;#################################################
; ASSIGNMENTS
;#################################################
;CONSTANTS
;-------------------------------------------------
;LATCH & SPI
Mosi equ 95h ;SPI Mosi from uC to slave
Miso equ 96h ;SPI Miso from slave to uC
Sck equ 97h ;SPI Clk
;-------------------------------------------------
;DEFINED VARIABLES
;-------------------------------------------------
QikB equ 19H ;Interrupt HEX value, msb
QikA equ 18H ;Interrupt HEX value, lsb
;#################################################
; PROGRAM
;#################################################
org 00h
START: ljmp INITIAL
org 0033h ;Address past vectors
db 'Marcus O. Durham, PhD, PE'
;-------------------------------------------------
org 0080h ;Address past reserve
INITIAL:
MAIN:
;-------------------------------------------------
;PROCESS
lcall ADCIN ;read adc on spi
mov A,QikB ;MSB, channel 1
lcall SEROUT ;send to serial
mov A,QikA ;LSB, channel 1
lcall SEROUT ;send to serial
MAN9: ljmp MAN9 ;Halt
------------------------------------------------
Chapter 36 Serial Chips - SPI 277
ADCIN:
;-------------------------------------------------
; LTC1098, 2channel, 12-bit analog-digital convt
; Write 4 bit control message. Then do input.
;
; Write data to chip on rising edge:
; Set data, pulse hi, pulse low.
; Read data from chip on trailing edge:
; Pulse hi, pulse lo, read data.
;
; The LTC needs at least 10us after enable
; before first data bit is output.
; There is a 40Hz serial clock limit.
; The timing is for a 7.5 MHz crystal. So the
; delays will increase for 11 MHz.
;
;STOP CLOCK
setb SpiClk ;clock low for null
;ENABLE CHIP SELECT
; lcall ADCDES ;disable & shutdown
; lcall ADCSEL ;enabl falling edge
;READ 12 BITS, CH0
mov A,#0D0H ;wr cmd1101xxxx,ch0
; mov A,#0F0H ;wr cmd1111xxxx,ch1
mov B,#4 ;count bits shifted
lcall SPIMSBOT ;byte,MSB 1st
clr SpiClk ;clock low for null
mov B,#8 ;count bits shifted
lcall SPIMSBIN ;byte,MSB 1st
mov QIkB,A ;high byte in
mov B,#4 ;4 bits in
lcall SPIMSBIN ;byte,MSB 1st
mov QIkA,A ;byte w/ 0 fill LSB
;DESELECT
setb SpiClk ;hi before deselect
; lcall ADCDES ;disable & shutdown
278 Systems Design and the 8051 Durham
;NEXT CHANNEL
; lcall ADCSEL ;enabl falling edge
ADCI9: ret
;-------------------------------------------------
SPIMSBIN:
;-------------------------------------------------
; Read serially from the SPI starting
; with the most significant bit (MSB). Data is
; clocked from the device on falling clock edge.
setb Miso ;Make Sdat an input
SPMI1: setb Sck ;Clk high
nop ;AD7714 t6 time
clr Sck ;Clock bit from ADC
nop ;AD7714 t5 time
mov C,Miso ;Sdat bit to C
rlc A ;Rotate bit to C
djnz B,SPMI1 ;Get all 8 bits
clr Miso ;undo Sdat input
ret
;-------------------------------------------------
SPIMSBOT:
;-------------------------------------------------
; Send B-bits. Most significant bit(MSB) first
; Data is clocked in device on rising clock edge.
;OUT & WAIT
SPMO1: rlc A ;Rotate MSB to C
clr Sck ;Clock bit to ADC
mov Miso,C ;Bit to port pin
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
setb Sck ;CLK line high
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
Chapter 36 Serial Chips - SPI 279
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
nop ;Delay for ç & 40Hz
djnz B,SPMO1 ;Send all bits
ret
;-------------------------------------------------
Avatar do usuário
tcpipchip
Dword
 
Mensagens: 6560
Registrado em: 11 Out 2006 22:32
Localização: TCPIPCHIPizinho!

Mensagempor batpoa » 08 Nov 2010 21:30

ok,valeu mesmo vou dar uma progamada por aqui desde já agradeço.
batpoa
Bit
 
Mensagens: 6
Registrado em: 24 Jan 2009 20:51


Voltar para 8051

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x