PIC Selection for I2C Slave to MMC project

Discussion in 'Embedded Systems and Microcontrollers' started by rockrockmcrock, Jan 23, 2013.

  1. rockrockmcrock

    Thread Starter New Member

    Jan 6, 2012
    19
    0
    Hi guys,

    I posted on here a while back about a project I wanted to do http://forum.allaboutcircuits.com/showthread.php?t=64354

    I got some great advice and so went away to learn a little before taking on the project as I obviously needed to get some more skills.

    Anyhoo - it's time I think to tackle that original project - and from what I can see I need an 18F with >512b RAM that can operate at 4V with as few pins as possible (size constrained). However, this is my first selection so I'm a little overwhelmed by the choice. I'm erring towards the 18F2420 or 18F2450. Can any guru confirm if these suit or where I've gone wrong if they're unsuitable (so I can learn).

    --------------------------
    For Info the basic background for the project and it's details are below:

    Basically I need a PIC to act as an I2C slave reading and writing to an EEPROM and then when required writing the entire contents of that EEPROM to an MMC card or reading data from the MMC and writing it to that EEPROM. The EEPROM is required (I think) to act as a 'speedy' (both boot and addressable) 64K permanent memory block for small bits of data (<512B). Mind you I'm confused as a newbie a little here as I suspect I could do this with the PIC alone although physical size of the chip may be an issue. Clock speed will be 20MHz and is intended through an external crystal (as I'm familiar now with this!).

    Physical size of the circuit will be an issue as the board must be 23mm x 34mm, but small form factors should help here. The other thing I'm constrained by is my programmer. After some research I bought a cheap K150 knock-off (in case I didn't like electronics) and, surprise, it has worked well and I've built a few projects with it from around the web. I could upgrade it, but if I can get away with something I know and like that'd be cool.

    --------------------

    Cheers guys! I didn't really expect to enjoy this kind of stuff as much as I do - but have now been bitten by the bug - I'm sure electronics wasn't this interesting at school/uni! I just feel like such a noob :(

    RRMC
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    Not impossible... most every PIC18 (or all?) has the hardware to run I2C, and worst case you bit bang it out (though I seriiusly doubt you will have to).

    The hard part is the MMC card... do they look like SD cards I am not sure. Microchip has a library to read SD cards, you get full FAT files so you can even pull the card and look at it on a PC. MC's library is LARGE, there is a petite FS out there that is much smaller but I have never used (have my eye on it).

    What package is your constraint? Searching PIC18's for a 28/QFN I see the PIC18F26K22 which has 64K ROM and 32K RAM.. you need a lot of ram for a file system.

    As the price difference for a larger part is negligible I always start with a large device, then see if I can move down when the code is complete and I know what size I need.
     
  3. rockrockmcrock

    Thread Starter New Member

    Jan 6, 2012
    19
    0
    Thanks for the swift reply mate and Wow! That's a lot of RAM

    From scooting around the net over the last week I was under the impression that only "512b + program variable space" was all that was required. The 512b is needed as a scratch pad for writing each FAT16/32 sector to the MMC / SD. I was presuming it was like higher level programming where you wouldn't seek to write all 64K in the EEPROM to the MMC card at once, but would write it in 512b chunks - hence the choice of 18F family and ~700b RAM, as a minimum in my PIC choice. Although whether ~200b extra is enough to run the program I am unsure as I have no experience here.

    The "K150 programmer" is an Asian updated hardware "knock-off" version of the Kits-R-Us original K150. It runs fine with the Kits-R-Us DIYPack software (although I could use others with a bit of hacking) but that is the constraining factor:
    I'm constrained to the following chips (all older) unless I want to upgrade my programmer.

    PIC18F242 PIC18F248 PIC18F252 PIC18F258 PIC18F442 PIC18F448
    PIC18F452 PIC18F458 PIC18F1220 PIC18F1320 PIC18F2220 PIC18F2320
    PIC18F2321 PIC18F4210 PIC18F2331 PIC18F2450 PIC18F2455 PIC18F2480
    PIC18F2510 PIC18F2515 PIC18F2520 PIC18F2525 PIC18F2550 PIC18F2580
    PIC18F2585 PIC18F2610 PIC18F2620 PIC18F2680 PIC18F4220 PIC18F4320
    PIC18F6525 PIC18F6621 PIC18F8525 PIC18F8621 PIC18F2331 PIC18F2431
    PIC18F4331 PIC18F4431 PIC18F2455 PIC18F2550 PIC18F4455 PIC18F4550
    PIC18F4580 PIC18F2580 PIC18F2420 PIC18F2520 PIC18F2620 PIC18F6520
    PIC18F6620 PIC18F6720 PIC18F6585 PIC18F6680 PIC18F8585 PIC18F8680

    Even with this constraint there are an awful lot of PICs there to choose from when you're a noob and working out the right one is confusing the $£%!! out of me.

    I could even use the 16F series, but I'd have to use F-RAM to get the 516b scratch pad size, which I imagine would increase programming complexity so I haven't gone this way....at present. However, there is a ready made SD/MMC to PIC circuit on the web for this approach.

    As to the difference/preference between SD/MMC - from my perspective (higher level programmer) there is none. SD has a 'lock disc' feature, but other than that all seem to work in any device and the protocol (at my level in the stack) is the same. I'd gone for MMC just because I presumed the lock feature would add complexity to interfacing with it - micro SD would actually be a better choice if this is not so!
     
    Last edited: Jan 23, 2013
  4. rockrockmcrock

    Thread Starter New Member

    Jan 6, 2012
    19
    0
    Opps! Just seen an error in my first post. The operating voltage should of course be 5v (not 4v)....darn touch typing skills....grrr!
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    Ah... I was wondering why 4V was the sweet spot... just keep in mind MMC runs off 3.3V. I'm in the middle of an app now running most things on 3.3 makes zero level conversion... except for the LCD display, but going 3.3 to 5V just takes a resistor.

    I'm using a microSD card... no write protect on that thing. Curiously, my library from Microchip doesn't have that option so I had to change some of their code to suit.

    I will strongly advise you to get a "real" programmer such as the PICkit 3, which also works as an in-circuit debugger if you can spare 2 I/O pins.

    In circuit debugging is really really essential.

    Really. <grin>
     
  6. rockrockmcrock

    Thread Starter New Member

    Jan 6, 2012
    19
    0
    I did wonder about how that and how far a simulator would go once I started doing more than messing with other peeps projects :D

    Yeah - perhaps it is time to upgrade the K150.

    Sad really, as I've seen loads of posts slating the K150s etc. but as an intro to microchip circuits for a beginner they are great if you know your way around a windows OS and the Google. They do exactly what they say on the tin (program chips) and they do it simply, all for $8 and you pretty much get your money back on the parts you can salvage at the end ;) I'll be sad to see the old guy go really....

    BTW I wasn't aware microSD cards had any different protocol to SD - am I going to have to hack the SD library around to get them to work then?
     
Loading...