Shop OBEX P1 Docs P2 Docs Learn Events
Building CMUcam4 C Environment - Need Help — Parallax Forums

Building CMUcam4 C Environment - Need Help

KyeKye Posts: 2,200
edited 2012-09-05 12:54 in Propeller 1
I'm working on making a C environment for programing the CMUcam4 in. In particular I need to make to customized cache driver for XMMC mode and then build some assembly functions for capturing image data and doing other low level things. I need the cache driver to support sharing of the I2C bus and work at 1 MHz.

Where should I start?

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2012-08-30 19:19
    Kye wrote: »
    I'm working on making a C environment for programing the CMUcam4 in. In particular I need to make to customized cache driver for XMMC mode and then build some assembly functions for capturing image data and doing other low level things. I need the cache driver to support sharing of the I2C bus and work at 1 MHz.

    Where should I start?
    What kind of external memory does the CMUcam4 have? Will it be shared between the cache driver and some other use?

    By the way, your board looks very nice! I just looked at the SparkFun page for it. Quite impressive!
  • David BetzDavid Betz Posts: 14,516
    edited 2012-08-30 19:33
    David Betz wrote: »
    What kind of external memory does the CMUcam4 have? Will it be shared between the cache driver and some other use?

    By the way, your board looks very nice! I just looked at the SparkFun page for it. Quite impressive!
    I just looked at the CMUcam4 schematic and the only external memory I see is the EEPROM and an SD card. Did you want to use one of those for XMMC?
  • KyeKye Posts: 2,200
    edited 2012-08-30 20:17
    I want to use the EEPROM as external memory for XMMC. I used 1 MHz EEPROM on the boards but it looks like the camera does not support more than 400 KHz so that is moot point. Mainly, I need to lock the I2C bus while I talk to the camera to initialize it. I was looking at the EEPROM cache driver and it seems to support locks... so... how can these be used with other I2C functions?

    I'd like to avoid have to work on parts of the code I do not absolutely need to edit. So, I'd like to reuse I2C code and serial code from propGCC for this project.

    ---

    Once I get everything working I will need to edit all the cache driver code and such to support the ability to turn off. I need to be able to shutdown all cores but core 0 and lower the clock frequency to RC slow to reduce power consumption. I can work on this after getting an image differencing environment setup.

    I need to use XMMC because I will be using 19200 bytes of memory for a frame buffer. I anticipate that I will run out of code space once external libraries are included.

    I have 64 KB of EEPROM on board for XMMC. I do not want to use an SD card because it will increase the static current draw. I can run at about 600 uA on my black Lextronic CMUcam4 model when sleeping.

    ---

    What I'll be making is a C interface library for the CMUcam4 for frame differencing. So, I plan to document everything I do. However, I am also doing all of this for a class I'm taking called energy aware computing where the class project involves building some computer system that is aware of its energy draw and tries to reduce it. My project is to use the CMUcam4 to monitor any changes in the room and turn the lights and HVAC system on when the room is occupied. I have to combine smart sampling of the room for occupancy with the goal of drawing as little current as possible. The goal for the project is to make the final device smarter than the PIR motion detector sensors in rooms which turn the lights off on you when you sit down for too long.

    Thanks,
  • David BetzDavid Betz Posts: 14,516
    edited 2012-08-30 20:31
    Kye wrote: »
    I want to use the EEPROM as external memory for XMMC. I used 1 MHz EEPROM on the boards but it looks like the camera does not support more than 400 KHz so that is moot point. Mainly, I need to lock the I2C bus while I talk to the camera to initialize it. I was looking at the EEPROM cache driver and it seems to support locks... so... how can these be used with other I2C functions?

    I'd like to avoid have to work on parts of the code I do not absolutely need to edit. So, I'd like to reuse I2C code and serial code from propGCC for this project.

    ---

    Once I get everything working I will need to edit all the cache driver code and such to support the ability to turn off. I need to be able to shutdown all cores but core 0 and lower the clock frequency to RC slow to reduce power consumption. I can work on this after getting an image differencing environment setup.

    I need to use XMMC because I will be using 19200 bytes of memory for a frame buffer. I anticipate that I will run out of code space once external libraries are included.

    I have 64 KB of EEPROM on board for XMMC. I do not want to use an SD card because it will increase the static current draw. I can run at about 600 uA on my black Lextronic CMUcam4 model when sleeping.

    ---

    What I'll be making is a C interface library for the CMUcam4 for frame differencing. So, I plan to document everything I do. However, I am also doing all of this for a class I'm taking called energy aware computing where the class project involves building some computer system that is aware of its energy draw and tries to reduce it. My project is to use the CMUcam4 to monitor any changes in the room and turn the lights and HVAC system on when the room is occupied. I have to combine smart sampling of the room for occupancy with the goal of drawing as little current as possible. The goal for the project is to make the final device smarter than the PIR motion detector sensors in rooms which turn the lights off on you when you sit down for too long.

    Thanks,
    You don't really need to use locks to share the I2C bus if you're careful. All you really need to do is guarantee that the code that accesses the camera does not cause a cache miss. You can do that by putting the low-level I2C access functions in hub memory using HUBTEXT. For example,
    #include <propeller.h>
    
    HUBTEXT void my_i2c_function(void)
    {
       // do whatever low-level stuff you want to do with I2C
    }
    

    Since this code is in hub memory it won't cause a cache miss and hence the cache driver won't be called. The trick, of course, is to make that function as small as possible. Do all of the complicated stuff in code that lives in external memory and do the minimum I2C driver access code in this function.

    However, you may still run out of memory since you'll need to allocate some space to the cache. If you're going to be using almost 20K for buffer space that doesn't leave much for your other program data and the cache.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-09-04 13:28
    Hi Kye,

    I understand you're doing a new version of your CMUcam for Parallax. Any chance you would consider adding a Quad-SPI flash chip to it for xmmc use? Even a regular SPI flash chip would be faster than trying to run xmmc code from the EEPROM.
  • KyeKye Posts: 2,200
    edited 2012-09-05 06:33
    I don't have any I/O pins left...

    Take a look at the schematic and see where you could put it... The only really unused pin is the TV_C pin which is used for TV broadcast stuff. Since my TV driver just does baseband that pin could be used for CS. Then the rest of the pins could be shared with the SD card. The camera D0 and D1 pins are also unused... but, I reserved them for future use.

    I would add it... but, I don't want to change the hardware for such that a firmware for my last two designs aren't compatible with the Parallax board.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-09-05 06:39
    Kye wrote: »
    I don't have any I/O pins left...

    Take a look at the schematic and see where you could put it... The only really unused pin is the TV_C pin which is used for TV broadcast stuff. Since my TV driver just does baseband that pin could be used for CS. Then the rest of the pins could be shared with the SD card. The camera D0 and D1 pins are also unused... but, I reserved them for future use.

    I would add it... but, I don't want to change the hardware for such that a firmware for my last two designs aren't compatible with the Parallax board.
    Well, CS plus sharing pins with the SD card would work for a single bit SPI flash chip. That would be faster than EEPROM and also have more capacity. However, as you say, if you make use of that feature the resulting software won't work on the Sparkfun board. What is the difference between the Sparkfun board and the Parallax board?
  • KyeKye Posts: 2,200
    edited 2012-09-05 12:54
    The Parallax board will have the same electrical setup of the Lextronic or SparkFun board.

    I can make some solder mask jumpers available on the board. This will allow you to switch in new functionality when you want by manually modifying your board.

    Thanks,
Sign In or Register to comment.