Shop OBEX P1 Docs P2 Docs Learn Events
I2C_ROMEngine Clearing a Block of Memory — Parallax Forums

I2C_ROMEngine Clearing a Block of Memory

Chuck MintonChuck Minton Posts: 45
edited 2016-02-12 02:44 in Propeller 1
Hello friends, it has been a while.

I am attempting to improve on a project I completed a couple of years ago and I need help.
This project is a voice prompted, telephone answering machine providing remote access to 12 momentary relays and 4 latch relays with a Realtime clock on board.
The old project wrote data into the upper area of the 24LC512 512Kb memory chip where the propeller won't get to it : $8000 and $8100.
I was using 2 separate fields of data 20 Longs long( one for each relay coil). The new project needs to increase the $8100 field by a multiple of 12 (one set for each month so it will run all year without resetting the relay time table).


One of my options at the display input in my project is to clear all memory and reset the entire relay timetable back to fresh. This, I thought would be a simple task : but has got me stuck. I finally took the write block out of the full program just so I could see and make trials quickly to get a handle on this. I am hoping that someone could point out to me the obvious that I am not seeing:

Considering X in the write to memory line : My project requires me to write the Long$00000008 into each memory location and I am not getting consistent reading back out. So, I put in $00000000 and I got all zeros back with zero count. Then I put in $FFFFFFFF and zeros on the terminal but then counts up by 1 each reiterating pass on the read in the ADDING column: (Could this be reading an overflow ?)
Any other value I stick in at X , the numbers run all over the place out of order. I thought If I put in 1 for instance that this operation would count up by 1, and if I put in 2 it would count up by 2. When I put in the value I need I get varied readback. At this point I am just trying to prove to myself that I am indeed writing to and reading from the memory properly. Each byte of the LONG is [3]seconds, [2]minutes, [1]hours, [0]day of week.

Thanks for your consideration and suggestions
/Chuck


My programming is as follows:
CON

  _clkmode     = xtal1 + pll16x           ' Feedback and PLL multiplier
  _xinfreq     = 5_000_000                ' External oscillator = 5 MHz

 DEBUG=0
         

OBJ


                  ROM:     "I2C_ROMEngine"
                 DATA: "pcFullDuplexSerial4FCMod.spin"




PUB START
                                       ''********INITIALIZE COM PORTS : ASSIGN PORT #'S*********
  DATA.Init                '' PORT/rx/tx/cts/rtspin pin number
  DATA.AddPort(DEBUG,31,30,DATA#PINNOTUSED,DATA#PINNOTUSED,DATA#DEFAULTTHRESHOLD,DATA#NOMODE,DATA#BAUD9600)   'debug 

   ROM.ROMEngineStart(29, 28, -1)         ' start the EEPROM READ/WRITE ENGINE

   waitcnt(clkfreq *3 + cnt)
   DATA.txflush(0)
   DATA.rxflush(0)
   MEMORYWRITETEST




PUB MEMORYWRITETEST    | Q  , Y , T2
 
      

      WAITCNT (CLKFREQ *4 +CNT)                                '' So I have time to get PST up and connected
      REPEAT Q FROM 0 TO 239                                     '' 2016 mod WAS : REPEAT Q FROM 0 TO 19   NOW:960 BYTES /(4BYTES/LONGS) = 240 LONGS 
                    ROM.WRITELONG ($8100 + Q  ,  X )            
                 

      REPEAT Q FROM 0 TO 239           
                    Y:=ROM.readLONG ($8100 + Q)
                    T2:=T2+ Y
                    
                    DATA.DECX(DEBUG,T2 ,14)                     ''Print out total read from memory
                    DATA.TX(DEBUG,44)
                    DATA.DECX(DEBUG,Y ,9)                         ''Print out value read from memory
                    DATA.TX(DEBUG,44)
                    DATA.DECX(DEBUG,Q ,3)                        ''Print out reiteration enumeration   
                    DATA.TX(DEBUG,13)


Comments

  • JonnyMacJonnyMac Posts: 8,923
    edited 2016-02-12 01:41
    Comment deleted by JM
  • THANK YOU Chris Savage !!!
    on one of your posts you put out a program that is sooo simple to use.
    It reads the address of the EEProm at hex address requested.
    This has made life so easy . I did not know if my reading was wrong or my writing was wrong, but this solved the problem.
    I have found that the writelong and readlong are not working for some reason and the use of writebyte and readbyte work
    just fine in the i2c_romengine and am using. So, just a matter of writing byte by byte.

    I have to encourage anyone who is wondering what the heck is going on up there in that eeprom over $8000 to try it.
    Easy not a bunch of config.

    Thanks Chris . I would have been here another week pulling the hair out of my already bald head.

    http://forums.parallax.com/discussion/download/88528/EEPROM_Monitor_Demo.zip
  • Cluso99Cluso99 Posts: 18,069
    A typical problem when using longs is the endian issue where the bytes are reversed. This shows up when bytes work and word/longs don't.
  • Cluso99,
    I was thinking about that possibility and, for that reason, I used binary so I could manipulate the bits being written but I could not find that the Big Endian or the Little Endian or any of the endians in between were causing me confusion.
    I am also writing to a DAT Table, and like you say, there I had to pay attention: however, unlike writing to the EEProm, writing to the DAT Table works great.

    After reading the data sheet on the chip, I see I need to give a go at page writing, especially in a situation like this because I read that the entire memory page is re-written after each byte is wrote. So, If you write 128 bytes on the page you are really burning up your chips lifetime by 128 Fold. Now, in this Project I can not see this to be too big of an issue once in use, but on the bench here, I sure would not want to let a loop get loose doing this deed.... at least without a soldering station at hand.

    Thanks !
  • Cluso99,
    I think you are right on the endian errors, and I just can't get a grip on it yet.
    So, now just using bytes to write, that is not a problem for this program: but I need to settle those little endians in my head.

    After reading on the memory writing and realizing the WRITE WEAR on each page, I see that there are plenty of memory pages left to write to available. I only need 240 data sets and that will fit easily into the remaining memory. This will reduce the wear to each page by a huge factor.
    I thought I would attach the code that does work.
    
    PUB MEMORYWRITETEST    | Q  , Y[4] , T2
     
          T2:=0                                                                              'T2 SEQUENTIAL WRITE VARIABLE
             WAITCNT (CLKFREQ *3 +CNT)                    ' GIVE ME ENOUGH TIME TO GET PST UP AND CONNECTED
         
                                                                                                                             
             REPEAT Q FROM 0 TO 30592 step 128       ''writes FIRST LONG to 239 pages from 8100  : ADDRESS:$F880 or 63,616
                        ' T2:=T2+1                                                         'T2 WHEN TESTING SEQUENTIAL WRITE
                       DATA.DECX(DEBUG,T2 ,10)
                       DATA.TX(DEBUG,44)
                        ' ROM.writeBYTE($8100+(Q),T2)                           'TEST WRITING TO EACH MEMORY PAGE SEQUENTIAL
                       ROM.writeBYTE($8100+(Q),8)        '' WRITE AN 8 TO THE DAY VARIABLE : 8== "NO DAY" OPERATION
                       ROM.writeBYTE($8100+(Q+1),2)    '' WRITE ZEROS FOR ALL TIMES                    
                       ROM.writeBYTE($8100+(Q+2),3)
                       ROM.writeBYTE($8100+(Q+3),4)
    
      
    
               
             REPEAT Q FROM 0 TO 30592  STEP 128         
                        Y[0]:=ROM.readBYTE ($8100 + Q)          ''READ MEMORY ADDRESS
                        Y[1]:=ROM.readBYTE ($8100 + Q+1)
                        Y[2]:=ROM.readBYTE ($8100 + Q+2)
                        Y[3]:=ROM.readBYTE ($8100 + Q+3)
                        
                        DATA.DECX(DEBUG,Y[0] ,9)
                        DATA.TX(DEBUG,44)
                        DATA.DECX(DEBUG,Y[1] ,9)          '' PRINT OUT MEMORY ADDRESS
                        DATA.TX(DEBUG,44)
                        DATA.DECX(DEBUG,Y[2] ,9)
                        DATA.TX(DEBUG,44)
                        DATA.DECX(DEBUG,Y[3] ,9)
                        DATA.TX(DEBUG,44)
                        DATA.DECX(DEBUG,Q ,6)
                        DATA.TX(DEBUG,13)
    
    
Sign In or Register to comment.