Shop OBEX P1 Docs P2 Docs Learn Events
Propeller JVM Project: PASM Java VM - Page 8 — Parallax Forums

Propeller JVM Project: PASM Java VM

1456810

Comments

  • ChimChim Posts: 16
    edited 2010-05-06 06:42
    jazzed said...
    Ok, I'll have to put together a test and try to reproduce the problem using an I2C EEPROM routine (since I don't have PCF8591). Is there already an I2C EEPROM access test for Javelin? There is some built-in stuff, but that won't help this. Sorry it's not working for you this time.
    Hi jazzed,
    Here is my new home-made test program with a 24LC256 EEPROM chip·that I made quickly and tested.
    Have a Look at this and tell me more about it.
    See you soon.
  • ChimChim Posts: 16
    edited 2010-05-06 08:42
    Hi,
    I have got a clue because on the version 04_18, it's works.

    See you later...
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 10:48
    I have a bunch of 24LC256 (spare parts for my memory extension). I will test all of that this evening since I will have no access to my prop today...

    JM
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 13:45
    Chim
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 15:41
    I2C.java uses CPU.java. For it to work with Propeller, we have to change CPU.java.
    I propose folding all PROP.java code into CPU.java and deprecating PROP.java.
    Current PROP.java becomes an alias for CPU.java and can be removed later.

    This would allow supporting all existing Javelin code which was written without regards
    to the possibility that a new CPU class could be used (an OOP methodology failure).

    I've included a new CPU.java, PROP.java, EE24LC256.java and a version of
    I2CTest.java that should work fine without GC enabled.

    I'm thinking EE24LC256.java should be generalized, however that may be redundant
    because the JVM has eeprom code built-in.

    Note the first EEPROM read should give 0x04A0B400 for an 80MHz clock program.

    OUTPUT:
    Step 1Step 2Step 3
    04A0B400
    Step 4__0__0__0__0__0__0__0__0__0__0__0__0__0__0 ...
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    May the road rise to meet you; may the sun shine on your back.
    May you create something useful, even if it's just a hack.
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 17:58
    Hi Jazzed,

    Not sure how to used the I2CTest.spin file. Content look strange. Can you please let us know?

    Regarding CPI vs PROP, I think it's a good approach.

    Thanks,

    JM
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 18:04
    Oops. Wrong file. Try the new one.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    May the road rise to meet you; may the sun shine on your back.
    May you create something useful, even if it's just a hack.
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 18:09
    Attached is an updated version for CPU including the 16 bits assignation Peter did.

    JM
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 18:25
    @jazzed:

    Just tried the EEPROM test file, and it's not working for me with the last JVM and you EE class. It'S freezing on eeI2C.isPresent().

    I'm using the EEPROM on the PPDB board, and, I promess, there is no wrong wire on the PIN28 and PIN29 holes [noparse];)[/noparse]

    JM
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 18:38
    It's freezing in I2C start method
    while (!CPU.readPin(sclPin)) {}       // wait for clock hold to release
    
    



    Maybe there is some pin configuration missing?

    JM
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 19:02
    @JM, Did it work with the code I posted? It worked fine for me as posted.
    Don't forget to post your test code so I can try to reproduce your problem [noparse]:)[/noparse]
    Meanwhile, I'll test your new CPU.java.

    Cheers,
    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    May the road rise to meet you; may the sun shine on your back.
    May you create something useful, even if it's just a hack.
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 19:08
    Hi Steve,

    Here is my code. It's a cut and past from your's.

    EE file is the one you sent too. I'm using JVM 0503.

    JM

    import stamp.core.CPU;
    import stamp.peripheral.io.EE24LC256;
    import stamp.peripheral.io.I2C;
    import stamp.util.text.Format;
    
    
    
    public class SerialLCDTest 
    {    
        
        public static void main ()
        {                
            System.out.println ("SerialLCDTest.java v2.4");
            
            System.out.println ("\nStarting EE24LC256 test...");
            
            I2C ioBus = new I2C(CPU.pin29, CPU.pin28);
            EE24LC256 eeI2C = new EE24LC256(ioBus,0x00); 
          
            System.out.print("Step 1");
          
            if(!eeI2C.isPresent())
            {
                System.out.print("EEPROM Not Found.");
            }
            else
            {
                System.out.print("Step 2");
              
                //readTest(ioBus, 0,0);
        
                CPU.writePin(CPU.pin0,false);
              
                System.out.println("Step 3");
                boolean readloop = false;
                do 
                {
                  for(int n = 3; n >= 0; n--) 
                  {
                    Format.printf("%02x", eeI2C.read(0x00,n));
                  }
                  System.out.print("\r\n");
                }
                while ( readloop );
            }
            
            while (true);
        }
    }
    
    
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 20:32
    jmspaggi said...
    Here is my code. It's a cut and past from your's.
    Ok, I added the new CPU.java to my library and compiled with your post. Here's what I get:

    Serial
    LCDTest.java v2.4
    Starting EE24LC256 test...
    Step 1Step 2Step 3
    04A0B400
    // looptest is set false, so only one long is printed.
    
    


    I think I want to move beyond .zip source sharing and use source control sharing. I'll do that later.

    Meanwhile here is an JVM update based on my current directory for you to try. There are few differences.
    Please try running the JVM without recompiling the Java code. The jem.bin should show the above output.

    Cheers.
    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    May the road rise to meet you; may the sun shine on your back.
    May you create something useful, even if it's just a hack.
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 20:48
    No working for me [noparse]:([/noparse]

    SerialLCDTest.java v2.4_       
    Starting EE24LC256 test...     
    Step 1                         
    
    



    I have extracted the entire zip, including the jem, and I have not recomiled anything.

    Pins 28, 29, 30 and 31 are free on the board.

    I don't really know what to try. Code is quite simple. I tried from the jem file you sent, and tried also to recompile locally. Same result.

    Are you testing on the PPDB?

    JM
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 21:13
    jmspaggi said...
    No working for me [noparse]:([/noparse]

    SerialLCDTest.java v2.4_       
    Starting EE24LC256 test...     
    Step 1                         
    
    



    I have extracted the entire zip, including the jem, and I have not recomiled anything.
    ...
    Are you testing on the PPDB?

    Ok, I was testing on Propeller Protoboard. Tried it on PPDB and got your result.
    At least I can reproduce the problem ...

    Can you put a 2.2KOhm (up to 10KOhm) pull up resistor on P28? I did this for my PPDB and it works.
    I think someone is relying on that for the start/stop conditions in the I2C driver.

    Cheers.
    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    May the road rise to meet you; may the sun shine on your back.
    May you create something useful, even if it's just a hack.
  • ChimChim Posts: 16
    edited 2010-05-06 21:47
    Hi,
    It's working now with PCF8591 (Version 05_03 and 05_06), How do you do to enable GCOLLECT under BST ? (Syntax ?)

    And I tried JVM 05_06 too without recompiling the Java code.
    I get:
    LCDTest.java v2.4
    Starting EE24LC256 test...
    Step 1Step 2Step 3
    04C4B400

    Marco
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-06 21:51
    With the pull up:
    SerialLCDTest.java v2.5_
    Starting EE24LC256 test...
    Step 1Step 2Step 3
    04C4B400                  
    
    



    I have 8 EEPROMS connected to my Javelin. I will have to see if I have this pull up or not.

    So Chim
  • ChimChim Posts: 16
    edited 2010-05-06 22:06
    Ok for me.

    Just, tell me how do you do to enable GCOLLECT under BST ?

    It's already late for me, I'll try another thing tomorow... Tell me what you need to test on JVM yet ? I'll try to help you.

    Bye.
  • jazzedjazzed Posts: 11,803
    edited 2010-05-06 22:51
    Yay! Thanks for your patience @JM and @Chim
  • ChimChim Posts: 16
    edited 2010-05-11 08:34
    Hi,
    it seems to me the GCOLLECT don't work on the last version...

    If you could put each version JVM on the file, It would be better too.

    See ya
  • jazzedjazzed Posts: 11,803
    edited 2010-05-11 12:36
    Chim
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-11 12:52
    Jazzed said...

    On a positive note, I found what's causing 0 to be output on the console

    Cool. That's a good news! [noparse];)[/noparse] But what's about the timer issue? [noparse];)[/noparse] (Just to add on the pressure) [noparse];)[/noparse]
    Jazzed said...

    I'll be removing GCOLLECT.

    There is no GC on the Javelin. So I think that it's not a big issue. Code done for the Javelin will still work on the Propeller.

    Personnally, I prefer to handle the memory myself. It's sometime asking my brain to works a but more, but that's what I like with the dev.

    JM
  • ChimChim Posts: 16
    edited 2010-05-11 13:39
    What's a pity because GC is a powerful function...but I understand.
    I've got another inquiry, I would be interested by long datas type in my program.
    Can you make a version of JVM with long data type by putting a define or it's too early ?
    I know I ask you a lot of things...

    See you later.
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-11 14:25
    @Chim
  • ChimChim Posts: 16
    edited 2010-05-11 14:53
    Good ! I had not thought to it ! Can you give me a modified file ? After I'll try...

    THANKS !
  • jazzedjazzed Posts: 11,803
    edited 2010-05-14 14:20
    @JM, @Chim
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-14 14:53
    Yep, I figured you barely disapears [noparse];)[/noparse] See you in June.

    In the meantime, I'm learning Spin and Pasm...

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-05-21 15:24
    Hi guys,

    Good to see you got the I2C issue solved by pulling up SCL.
    (slave devices may extend SCL that's why a pullup is required).

    Someone mentioned generalizing I2C.
    I have already done that using classes I2Cdevice (abstract class), I2CsmFastDevice (extends I2Cdevice and uses shiftIn and shiftOut),
    and I2CsmDevice (extends I2Cdevice but does not use shiftOut). I2Cdevice supports both 7-bit and 10-bit addressing.

    http://tech.groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/protocol/i2c/


    For example, an rtc and eeprom would be declared as
    · //rtc
    · static I2CsmDevice DS1307_CHIP = new I2CsmDevice(pinSDA,pinSCL,0xD0|I2Cdevice.ADDR8,32767,1,1); //DS1307 rtc, no pagewrite delay
    ··static I2Cmemory backupRam = new I2Cmemory(DS1307_CHIP,8,56); //general memory class
    · static DS1307 rtc = new DS1307(DS1307_CHIP);
    · static Calendar cal = new Calendar();
    · //eeprom
    · static I2CsmDevice MC24LC32A_CHIP = new I2CsmDevice(pinSDA,pinSCL,0xA0|I2Cdevice.ADDR16,32,128,105); //MC24LC32A eeprom, 5ms pagewrite delay

    Using I2CsmDevice you don't need bother about start() and stop(). That class also supports block read/write using pagewrites to speed up writing.

    For long support, there is already the Int32 class which provides add, sub, mul, div on 32bit numbers.
    (it uses 2 int's to represent a long just as jmspaggi suggested).
    More math classes (floating point and trig)
    http://tech.groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/math/

    These should all work if the jvm operates correctly.


    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2010-05-21 16:56
    [noparse][[/noparse]code="Peter"]
    For long support, there is already the Int32 class


    Thanks for sharing! I have not yet start to code it, so it will save me some time.

    Regarding I2C, the only component I'm using so far is the EEPROM. But I have a bunch of Atmega talking I2C that might join my board a day [noparse];)[/noparse]

    JM

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Linux? There is worst, but it's more expensive.
  • jazzedjazzed Posts: 11,803
    edited 2010-06-01 20:37
    @JM, @Chim
Sign In or Register to comment.