Shop OBEX P1 Docs P2 Docs Learn Events
Propeller programmable I2C peripherals - PPC — Parallax Forums

Propeller programmable I2C peripherals - PPC

Peter JakackiPeter Jakacki Posts: 10,193
edited 2009-04-26 02:02 in Propeller 1
I have been having a bit of fun lately programming these cheap 8-bit micros as I2C slave chips for the Propeller. At present I am using the Silabs C8051F334(20-pin) but I am also working on the MC9S08SH. Both of these micros are very similar but the Freescale part is available in a variety of packages including DIP plus it can operate up to 5 volts.

What makes them appealing as I2C peripherals?
1) Cheaper than many I2C peripherals (Mouser 1 off 9S08SH4 for less than $2)
2) Includes Analog, Temperature, Digital I/O, timers/pwm, serial interfaces and RTC
3) Can be reflashed with new firmware in-circuit from the Prop using one dedicated I/O (or jumpered)

For those who are interested I will be making the Silabs C2 and Freescale BDM drivers available in Spin/PASM along with the I2C firmware images and source (for those who dabble). I really only load the programming software into RAM (F10) as I need it as it runs, reflashes the chips, then reboots back into the EEPROM application, all within a matter of a few seconds.

I am already using these chips in my designs but this will certainly be of interest to many forum members who use I2C chips. I initially used these for versatile A/D converters but I am now doing so much more with them and they have enabled me to offload the more mundane I/O tasks (and pins) from the Prop.

I have some of these chips monitoring the voltages on MOSFET drivers which the Prop can interrogate but more importantly the chips are programmed to automatically disable the drivers the instant they misbehave (overloads etc). Another chip is running a bunch of LED shift registers, dimming, and reading switches off the I2C bus. Admittedly I have one dedicated I/O line per chip just for reprogramming but it's worth it.

The level of interest I receive will dictate how much effort I put into polishing and documenting these chips for the forum. Let me know of any special requirements and I might be inclined to include that in the firmware.

*Peter*
533 x 248 - 12K
487 x 368 - 17K
«1

Comments

  • TubularTubular Posts: 4,706
    edited 2009-03-12 20:30
    Hi Peter,

    I have to admit the price makes those devices looks them very compelling. I have played with the Silabs but not the Freescale (yet). I'm very interested in the possibility of doing away with the prop EEPROM and booting via the slave micro (for small prop programs)

    There are some interesting versions of the C8051F such as the C8051F930. It has an internal charge pump and cap operate off 1 battery cell and supply 65mW externally (enough to run the prop??) . Also some of their others had nice fast ADCs

    While the Silabs aren't available in DIP the daughter cards for $10 including pre soldered CPU make it very easy

    I'm happy to dabble and test and see what can be done

    tubular
  • kwinnkwinn Posts: 8,697
    edited 2009-03-12 21:33
    Looking forward to your posts Peter. I am very interested in using that approach to replace the mass of individual wires that runs from PLC's to sensors with a power distribution cable and serial bus in one 3-4 conductor cable.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-12 22:21
    @kwinn,
    There is no reason to use the I2C bus either since these chips have proper 8/9-bit UARTS so it is possible to talk to them easily full or half duplex serial from the Prop. In one application I have an I2C chip also monitoring the main serial receive line and it can receive a remote command over the network and place the Prop into reset while it loads up the EEPROM directly, so it's also handy for bootloading the Prop over RS-485 and radio networks.

    @tubular
    My emphasis will be on the Freescale part on this forum because of it's price and packaging but I am still playing with that chip at present. If you really like the Silabs parts and don't mind soldering 20-pin QFNs I can tidy up the project and post that material. Wouldn't a $10 daughter card be a bit prohibitive for most?

    *Peter*
  • RaymanRayman Posts: 14,826
    edited 2009-03-12 23:39
    The price is right!

    Have you figured out how to program it with a Prop over the 1-wire interface?

    Or, how are you programming it?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-13 00:22
    I have the C2 protocol working on the Silabs parts as I use the SDA for the C2D line and a dedicated I/O for the C2CK/RESET line. For the Freescale part there is plenty of documentation plus I have a demo board with the BDM to reference so I don't expect it to be much of a problem, no more than the C2 was [noparse]:)[/noparse]

    I can pick up the 9S08SH4 chips for around $1 USD. How cheap is that! On the box that the demo board came in it says "So much integration at 5V, it shouldn't be called "low-end"". So my idea with these chips is to have "objects" just like we do with the Propeller expect the objects are Flashed into the PPCs. Actually the development environment for the MCS08 is quite interesting as it almost generates the code for you from the GUI using "beans". Just put them all together, this is truly "assembly" language smile.gif

    There are also versions with 16/32K of Flash which might be useful for EEPROM emulation as well.

    *Peter*
    1440 x 900 - 60K
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2009-03-13 00:47
    Peter,
    Sounds interesting but I went even lower down the freescale food chain to the MC9RS08KA. I got their 'KA2 demoboard last week. Eventually I want to make a couple smart rgb leds. (Though lately I have decided that 74hc595s are even cheaper and easier for my project. )

    Do you think you have anything that fits into the RS08KA?

    Fred
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-03-13 00:56
    I just ordered a buncha samples of the MC9S08SH family. I, too, am a big fan of extending the Prop via other fixed function and programmable devices.
    I mix PIC, OOPIC, CORIDIUM, I2C and P8X32A chips freely. I believe this agnostic predeliction is due to my professional design experience extending back to the TTL and RTL (paleolithic) eras.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-13 01:11
    Hi Fred,

    That chip certainly is down the end of the chain, maybe even dangling off it. I think you find that there is not much of a price difference once you get down to this level so you end up saving maybe 50cents but you are completely crippled compared to the MC9S08SH. The RS08KA can be used but it's usefulness would be very limited plus the I2C slave software would be completely bit-bashed anyway soaking up a fair percentage of the meager memory.

    @Jim: I believe I even have some uL911? chips floating around which if I remember is a single RS flip-flop or thereabouts.

    *Peter*
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-03-13 01:27
    Don Lancaster!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • kwinnkwinn Posts: 8,697
    edited 2009-03-13 01:30
    I was thinking of something small enough to build into a proximity sensor, temperature sensor, or thermocouple etc. and run a cable with 3 or 4 wires from one to the next to provide power and a serial data path. You would need to be able to program a specific ID number into the sensor before it is mounted in the equipment so the main software does not have to be changed when a sensor is replaced. Most of the sensors I work with are in a threaded tube about 4 inches long and 0.5 inch diameter with a connector on one end and the sensing area on the other end.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-03-13 01:34
    Peter Jakacki said...
    .... The level of interest I receive will dictate how much effort I put into polishing and documenting these chips for the forum. Let me know of any special requirements and I might be inclined to include that in the firmware.

    by all means Peter I am certainly interested ! Break out the polish !

    Regards,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-13 01:35
    Kwinn, that's why I chose the 08SH because you can go QFN or better the 16/20-pin TSSOP. Darn small and the TSSOP are easy to solder with a flat tip.

    *Peter*
  • TubularTubular Posts: 4,706
    edited 2009-03-13 02:32
    I'm getting some proto boards made next week and will make up a tiny adapter for 08SH (soic 8) to DIP8

    That way I can just plug it into the standard 24LC256 socket and test a smart i2c booter. Alternatively I can leave the existing E2PROM in and piggyback with the 08SH at i2c address 1

    Does anyone else have a use for such an adapter?

    tubular
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-03-13 02:45
    So the one of the main reason for using the micros proposed is because you can easily reflash them with one I/O from the Propeller?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-13 03:06
    Hi Tim, they actually need two control lines to reflash them but one of those lines I share with the I2C SDA line so you only need one other one. Since this line is only needed for flashing you could possibly share it with another I/O by means of a jumper if you were really skint with pins. Personally I find since these chips free up the Prop's I/O for more useful functions I usually have a spare pin or two available anyway.

    *Peter*
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-03-13 06:09
    Sounds very interesting Peter. Pitty the pinout doesn't match the 24C256 or the 74HC573 (power). I still like the prop, particularly with the new pricing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-13 06:44
    Ah yes Ray, but it's not about disliking the Prop (don't talk like that!), quite the opposite in fact. We are all accustomed to sourcing I2C and various peripheral chips to supplement the Prop but this way we have the one chip and there are no special MCPxxx or ADxxx drivers to write, just the standardized I2C access format for these chips and they do all the rest.

    *Peter*
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-03-13 11:34
    Say I have an SPI device I want to use, but want to do a little preprocessing on before using that data in the Prop to save a cog, could this be used an an intermediate device? Or are you proposing using these for just the basic functionality of A/D, temp, storage?
  • ErNaErNa Posts: 1,752
    edited 2009-03-13 11:40
    Hi Peter, I find your idea very usefull, especially as you started this project while I still think about it. Some time ago I found an SiLabs chip with 64KFlash and thought to emulate the bootflash function. This would save the boot flash and expand the I/O's. Just these short remarks, I didn't read the thread carefully, but will do it!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-03-13 11:41
    Does anybody have an opinion of wether these chips would be suitable as a sensorless brushless motor controller?
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-03-13 12:15
    Peter - perhaps I didn't explain properly. It would have been nice to have the power pins on the DIP20 on 10 & 20 so I could plug it in the 74HC573 position or likewise the pinout of the 24C256 so it could be a drop-in replacement. I understand the pricing and features of the Freescale IC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Old man EarlOld man Earl Posts: 46
    edited 2009-03-15 18:43
    I found a quick source for the 9s08 parts, and it comes with a Freescale 3 axis accelerometer. At Best Buy ! It is a Wii nunchuck knockoff for $15. It has 2 chips in it. Both Freescale. The 9s08 and the accl. It cuts electronically very nice so you end up with a 1 x 1 " ckt board with 4 wires. 3.3 VDD , Gnd, SCL and SDA. I have played with it on my prop board and see SOME data. Having trouble with the pin 28/29 i2c data, not getting data reliably. Is there a way via i2c to get to the chips innards ? I've been using the i2cObject.spin code and other ones with limited success. I'll post the code if anyone is interested.
    Earl
  • kwinnkwinn Posts: 8,697
    edited 2009-03-15 18:58
    Jay, while Peter is more familiar with these chips and this idea than I am, they are microcontrollers, and there is no reason they could not be used for both preprocessing sensor data or as a sensorless brushless motor controller. You just need to find one with the right amount of memory and I/O pins for the job.
  • Old man EarlOld man Earl Posts: 46
    edited 2009-03-16 00:17
    Do you think we can reprogram the nunchuck processor (9s08 Freescale 8 bit) to give more meaningful data ? BTW, the controller's accl chip has 2 pins to control sens. In reg mode its set for +-2g but can be changer to +_6g or two other by hi & lows on the 2 pins.Wii has the 2 pins hardwired, but 2 wires to 2 empty u-processor would make the accl programmable. Anyone else still looking at these ? I also see the 3 independant xyz analog voltages via o'scope. Don't quite have a handle on i2c communications on SCL SDA lines, but I can see it with o'scope again. How about putting the "K" filter in there ? Would free a cog in the prop.
    Earl
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-03-16 01:01
    I have attached a sample of my current PPC files including the C8051 assembler files for the PPC. At present this will only program the SIlabs parts which are not available in DIP. In the PPC PROJECT.ZIP file I have my included a vendor independent macro assembler which covers scores of processors including the C8051 and HCS08 cores. This obviates the need to download the huge IDE software packages from the vendors when all you want to do is assemble files.

    The spin program is standalone and works simply by loading to RAM. The user CHIPS table has a list of I2C slave addresses to assign to each chip that is programmed whereas the C2CK table indicates the dedicate C2CK line of the chip itself. This program works but has no way of reporting success or failure but was written as a quick-load. It is easy enough to tie this in with some other software to report status. My initial programs simply used serial communications and a command shell.

    I don't envisage anyone actually using these files as they are Silab specific however they are an introduction to the way I am using these chips as Programmable Peripheral Controllers or PPCs. In the next week or two I should have the MC9S08SH chip running and hopefully have the BDM driver completed to program these chips in-circuit.

    *Peter*
  • TubularTubular Posts: 4,706
    edited 2009-03-16 11:56
    Here's the promised MC9S08SH to DIP8 adapter / breakout.

    It's designed for the MC9S08SH32CTG (32kB flash, 16 pin TSSOP, I2C, 8 ADC inputs, 2 pulse outputs, and more... )

    The single wire background program/debug signal BKGD can be jumpered either to 24LC256 EEPROM Pin 1 (Normally A0), or to the Pin 5 (Normally SDA). Reset\ probably isn't required but can be jumpered across to Pin 3 (Normally A2) if required.

    I'll get a handful of these run tomorrow on an 8 WD proto service, so let me know asap if anyone wants

    tubular
  • ianwianw Posts: 32
    edited 2009-03-16 17:48
    Jay, The Atmega8's are commonly used for many of the commercial R/C blmc, and they run as fast as the MC9S08SH. A comparator is helpful and both chips have this. I think the most important bit of I/O though, is probably the available PWM's. The Atmega8 has 3 PWM's and (2) 8bit and (1) 16bit timer:
    http://www.atmel.com/dyn/Products/Product_card.asp?part_id=2004&ListAllAttributes=1

    When I've used DAQ's from various manufacturers a few pins can often be set as PWM or timers depending on which flag you set. Since I'm just now learning about lower level mcu development (Propeller and other options), I'm unsure if this would work the same way with the MC9S08SH (Peter likely knows though).

    From this diagram:
    http://forums.parallax.com/forums/attach.aspx?a=29237
    the MC9S08SH has 4 timers listed, but I don't know if they could easily be made into PWM's, or how many bits they are

    The Atmega firmware I've seen is usually written in assembly too, so I'm guessing you would need to write assembly for the MC9S08SH. Since your Kalman work on the Propeller shows a comfort with assembly, this may be no big deal for you. : )

    Post Edited (ianw) : 3/16/2009 5:53:24 PM GMT
  • TubularTubular Posts: 4,706
    edited 2009-03-17 00:20
    @earl,

    I saw something in the MC09SH manual about being able to remove security after doing a bulk flash erase.

    *edit* here's the text:
    "(The background debug controller can only do blank check and mass erase commands when the MCU is secure.)"

    I believe what they mean is "When the MCU is secure, the BDC can only do a blank check command or a mass erase command". I therefore assume you can perform these two commands plus many more when it is not secure.

    Looks like you should be able to re-program using the single background debug wire (pin 2)

    tubular

    Post Edited (Tubular) : 3/17/2009 1:42:58 AM GMT
  • Old man EarlOld man Earl Posts: 46
    edited 2009-03-18 02:30
    The wii nunchuck knockoff called the Edge available at Best But for $15 has a mc9s08 and a 3 axis accelerometer chip on it, all talk able via i2c to the prop chip. See my poat in the sandbox forum under cheap accelerometer.
  • TubularTubular Posts: 4,706
    edited 2009-03-23 01:32
    Peter,

    Looking through the expansive uC range there is also a QE series, which has a 12 bit ADC, and oddly may be cheaper than the SH (qty1).

    I'm no expert on Freescale stuff, and unlikely to become one in a hurry (the shortform alone is 52 pages!). Would the QE series also work with your Prop-initiated flash programming approach ?


    1 off Pricing from mouser (USD) on 4kb flash models
    MC9S08SH4CSC (SOIC-8, 10 bit ADC) $2.23
    MC9S08SH4CTG (TSSOP-16, 10 bit ADC) $1.85

    MC9S08QE4CTG (TSSOP-16, 12 bit ADC) $1.44
    MC9S08QE4CPG (DIP-16, 12 bit ADC) $1.44


    I updated the DIP8 adapter board to either take a TSSOP-16 on the front, and SOIC-8 on the reverse. A 12 bit ADC makes it useful for me commercially (rather than just an experiment)

    tubular
Sign In or Register to comment.