Hola peña:
Estoy simulando un 877 y una ee externa 25aa1024 con proteus.
Pero ... cáspitas! No me direcciona mas que 2 bytes! O sea que si le mando 3 bytes de direcciones, el tercero me lo toma como dato y el dato me lo toma como otro dato mas que me lo mete en la dirección siguiente! jajaja.
Alguno puede mirar si soy yo o el proteus solo simula una 25AA1024 como una 25aa256?
aqui el enlace al circuito proteus (ultima version) que contiene las memorias de 1mb
http://www.4shared.com/file/81749337/6ea33bf/1024PRUEBA.htmlY este es el programa:
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
; Filename: PIC16F877 SPI.asm
;
; Program Description:
;
; This program goes through the basics of SPI communication using the
; MSSP module for the PIC16F877. AN909 should be referenced for further
; explaination as far as what to watch out for and proper programming
; techniques for the SPI protocol. The program has examples of WRITE ENABLE,
; WRITE, READ, READ STATUS, and WRITE DISABLE commmands. There are also
; Scope plots of all these commands in the Application Note itself.
; The program write enables the device, writes one byte, polls the WIP
; bit, reads the data written, write disables the device and keeps running
; this sequence continuously.
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LIST P=16F877A
; Port C pin descriptions
; SCK bit = 3
; SDI bit = 4
; SDO bit = 5
; CS bit = 6
;
; 10MHz crystal is being used, thus each instruction cycle = 1600nS
;
;*******************RAM register definitions**********************
rxtxdata equ 20h
;txdata equ 21h
ADDRHIGH equ 21h
ADDRMED equ 22h
ADDRLOW equ 23h
loops equ 24h
;outbyte equ 24h
temp1 equ 25h
temp2 equ 26h
;*******************Bit definitions*******************************
CS equ 6
;*******************Include file**********************************
include "p16f877a.inc" ; this is the include file for a PIC16F877a
errorlevel -302 ; suppress message 302 from list file
; P16C877a.INC Standard Header File, Ver. 1.00 Microchip Technology, Inc.
;*****************************************************************
org 0x000 ; set the reset vector
goto start ; go to the beginning of main
start
bcf STATUS,RP0 ; set to bank 0
clrf PORTC ; initialize portc to 0
bsf STATUS,RP0 ; set to bank 1
movlw 0x10 ; all bits are outputs except SDI
movwf TRISC ; move the value to TRIS portc
bcf STATUS,RP0 ; set to bank0
bsf PORTC,CS ; make the chip select is high
clrf PIE1 ; disable peripheral interrupts
clrf INTCON ; disables all interrupts
bcf STATUS,RP0 ; set to bank 0
clrf SSPCON ; clear SSP control register
movlw 0x31 ; set up spi port, SPI master,
movwf SSPCON ; clk/16, ckp=1 (mode 1,1)
bsf STATUS,RP0 ; set to bank 1
clrf SSPSTAT ; clear SSP status register
movlw 0x80 ; set up spi port, SPI master,
movwf SSPSTAT ; cke = 0 (mode 1,1)
bcf STATUS,RP0 ; set to bank 0
movlw 0x00 ; put starting address 55 in
movwf ADDRHIGH ; addr for later use
movwf ADDRMED
movlw 0x01
movwf ADDRLOW
;Send the write enable sequence (WREN)
bcf PORTC,CS ; clear the chip select (active)
movlw 0x06 ; load WREN sequence
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
bsf PORTC,CS ; set the chip select line
;Send the write status register sequence (WRSR)
bcf PORTC,CS ; clear the chip select line
movlw 0x01 ; clear all status register
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
movlw 0x00 ; load up zero to send
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
bsf PORTC,CS ; set the chip select line
;Wait the required 5mS for the write cycle timer Twc
call delay ; call the delay subroutine
;Send the write enable sequence (WREN)
bcf PORTC,CS ; clear the chip select (active)
movlw 0x06 ; load WREN sequence
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
bsf PORTC,CS ; set the chip select line
;Send the read status register sequence (RDSR)
bcf PORTC,CS ; clear the chip select line
movlw 0x05 ; load RDSR sequence
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
call output ; read the data in status reg.
bsf PORTC,CS ; set the chip select line
;Send the write sequence (WRITE)
bcf PORTC,CS ; clear the chip select line
movlw 0x02 ; load WRITE sequence
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
;****************************************************************
movf ADDRHIGH,W ; load high address byte
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
;****************************************************************
movf ADDRMED,W ; load high address byte
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
;****************************************************************
movf ADDRLOW,W ; move the address into w
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
;****************************************************************
movlw 0x88 ; load data AA into w
movwf rxtxdata;outbyte ; store in RAM location outbyte
call output ; call the SPI output routine
bsf PORTC,CS ; set the chip select line
stop goto stop