18F1320 ... Strange Memory


Results 1 to 40 of 44

Threaded View

  1. #34
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I've studied two chips...

    Both have a Batch Code of 05250SE and a Silicon Revision of DEVID2=07h DEVID1=C4h (located at 3FFFFEh and 3FFFFFh respectively).

    This is my Test Code, run on internal Oscillator at 4 and then at 8MHz... compiled with PBP2.46 with patches and MPASM 5.01.

    Code:
    	'
    	'	EEPROM Test Program for PIC18F1320
    	'	----------------------------------
    	'	Melanie
    	'	07/04/2006
    	'	----------
    
    	'
    	'	PIC Defines
    	'	-----------
    	@ __CONFIG  _CONFIG1H, _IESO_OFF_1H & _FSCM_OFF_1H & _INTIO1_OSC_1H
    	@ __CONFIG  _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _BORV_20_2L
    	@ __CONFIG  _CONFIG2H, _WDT_ON_2H & _WDTPS_32K_2H
    	@ __CONFIG  _CONFIG3H, _MCLRE_OFF_3H
    	@ __CONFIG  _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVR_ON_4L
    
    	@ __CONFIG  _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
    	@ __CONFIG  _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
    	@ __CONFIG  _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
    	@ __CONFIG  _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
    	@ __CONFIG  _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
    	@ __CONFIG  _CONFIG7H, _EBTRB_OFF_7H
    
    	'
    	'	Hardware Defines
    	'	================
    		'
    		'	PIC Speed
    		'	---------
    	Define OSC 8
    
    		'
    		' 	LCD Display
    		'	-----------
    	Define LCD_DREG PORTB				' Port for LCD Data
    	Define LCD_DBIT 4				' Use upper 4 bits of Port
    	Define LCD_RSREG PORTB				' Port for RegisterSelect (RS) bit
    	Define LCD_RSBIT 3				' Port Pin for RS bit
    	Define LCD_EREG PORTB				' Port for Enable (E) bit
    	Define LCD_EBIT 2				' Port Pin for E bit
    	Define LCB_BITS 4				' Using 4-bit bus
    	Define LCD_LINES 2				' Using 2 line Display
    	Define LCD_COMMANDUS 2000			' Command Delay (uS)
    	Define LCD_DATAUS 50				' Data Delay (uS)
    		'
    		'	Other Ports
    		'	-----------
    	LED var PortB.0	
    
    	'
    	'	Software Defines
    	'	----------------
    	CounterA var BYTE				' Just a Counter
    	DataA var BYTE					' Byte Variable for Data
    	DataB var BYTE
    	EEPROMError var BIT				' Error Flag
    
    	'
    	'	EEPROM Presets
    	'	--------------
    	Data @0,"This is a Test String that should be overwritten"
    	Data	"by the Write to EEPROM routine"
    
    	'
    	'	Start Program Here
    	'	==================
    
    	'
    	'	Initalise PIC
    	'	-------------
    	OSCCON=%01110010
    	ADCON1=%01111111
    	TRISB=%00000000
    	Low LED
    	Pause 2000
    	High LED
    
    	'
    	'	Write to EEPROM
    	'	---------------
    	LCDOut $FE,1,"Writing EEPROM",$FE,$C0,"A="
    	For CounterA=0 to 255
    		DataA=255-CounterA
    		LCDOut $FE,$C2,#CounterA
    		Write CounterA,DataA
    		Next CounterA
    	LCDOut $FE,1,"Write Complete"
    	Pause 2000
    
    	'
    	'	Read & Verify EEPROM
    	'	--------------------
    	EEPROMError=0
    	LCDOut $FE,1,"Verifying EEPROM",$FE,$C0,"A="
    	For CounterA=0 to 255
    		LCDOut $FE,$C2,#CounterA
    		Read CounterA,DataA
    		DataB=255-CounterA
    		If DataA<>DataB then
    			LCDOut $FE,$C6,"E=",HEX2 DataB
    			LCDOut $FE,$CB,"R=",HEX2 DataA
    			EEPROMError=1
    			Pause 2000
    			LCDOut $FE,$C6,REP 32\11
    			endif
    		Next CounterA
    	LCDOut $FE,1,"Write Complete"
    
    	'
    	'	Result
    	'	------
    	LCDOut $FE,$C0,"Chip Test "
    	If EEPROMError=0 then
    		LCDOut "Pass"
    		else
    		LCDOut "Fail"
    		endif
    
    EndLoop:
    	Pause 500
    	Toggle LED
    	Goto EndLoop
    
    	end
    And the result?

    One chip fails miserably, and the other works perfectly. The appended picture shows the good PIC passing at 8MHz... frequency counter is measuring Internal Oscillator OUT on RA6 which is fosc/4.

    The PIC that failed did NOT write to EEPROM... it's previous contents were untouched, the Read section reported $FF from every memory Location (that had not previously been preset by a DATA statement). I have not had time to impliment the ERRATA (Section 10 Page 3) suggestions from Microchip and verify if the dud PIC works with one or both of them.

    Alain, email or message me your address off-list and I'll send you the working PIC - you can then see if your program works on that.
    Attached Images Attached Images  

Similar Threads

  1. Strange pic 16f877a memory loss
    By DavyJones in forum General
    Replies: 23
    Last Post: - 6th July 2009, 20:27
  2. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  3. Replies: 4
    Last Post: - 2nd March 2007, 06:12
  4. sample code for M25P32
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2007, 02:37
  5. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 18:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts