TODOPIC

Microcontroladores PIC => Almacén del Assembler => Mensaje iniciado por: pibe en 21 de Enero de 2009, 09:59:46

Título: 25LC/25AA1024 en proteus, fallo?
Publicado por: pibe en 21 de Enero de 2009, 09:59:46
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.html

Y 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



Título: Re: 25LC/25AA1024 en proteus, fallo?
Publicado por: micro_cadaver en 21 de Enero de 2009, 12:11:16
porque dices que el direccionamiento de dicha memoria tiene 3 bytes? en el datasheet sale esto:

(http://img179.imageshack.us/img179/2913/tttxo4.jpg)

byte de control = 1

direccion high byte = 1
direccion low byte = 1

data = 1
Título: Re: 25LC/25AA1024 en proteus, fallo?
Publicado por: sander en 21 de Enero de 2009, 12:46:10
Microcadaver la memoria que pibe esta usando es la 25AA1024 y lo que dice es cierto, en la hoja de datos se muestra que la direccion es de 24 bits , yo creo que es un error en el proteus, ojo que el proteus no es perfecto, ayuda mucho pero no es perfecto. yo le he encontrado algunos fallos.

Saludos.
Título: Re: 25LC/25AA1024 en proteus, fallo?
Publicado por: micro_cadaver en 21 de Enero de 2009, 14:10:13
ah groso detalle el que me salte  :o

ya lo dijo mi mama, comprate lente!!!!

confundi el 25 por 24
Título: Re: 25LC/25AA1024 en proteus, fallo?
Publicado por: pibe en 21 de Enero de 2009, 14:16:21
Pero digo yo una cosita:
Estos de labcenter no prueban un device cuando lo programan? O sea que dijeron "vamos a hacer un device nuevo, con el mapa de memoria de 1mb y el direccionamiento de 256k, o sea que solo copiamos la 25aa256, le ponemos nuevo nombre y que si no les alcanza que pongan 4 en paralelo " :P

No entiendo, yo creo que mi programa está bien, no?
Título: Re: 25LC/25AA1024 en proteus, fallo?
Publicado por: MGLSOFT en 22 de Enero de 2009, 02:23:24
PIBE.
Este es uno de los casos donde deberias tener un ICD para hacer debug SOBRE el circuito, y no simularlo, ya que te evitaria muchisimos dolores de cabeza, y menos roturas de teclados...je..je :mrgreen: