PPC (I2C Intelligent Peripherals) tools and code for SILABS 8051
Peter Jakacki
Posts: 10,193
As I mentioned in Cluso99's thread http://forums.parallax.com/showthread.php?t=126484 that I will try and post some 8051 code. Well I have zipped up the complete package which relies upon a free universal macro-assembler (included). With this package you can use the working sample of the 8051 assembly code as a template for your own PPC.
Run from DOS (or DOSBOX etc):
>ASM PPC
This will assemble the PPC file and generate a binary image called PPC.BIN which is used by the Spin code.
The Spin code is included and all you need to do is compile and load into RAM (F10) and it will program your PPC and reboot the Prop back into it's EEPROM code.
This sample code implements an I2C slave along with automatic ADC conversion and scanning of inputs. There are other commands to read and write I/O and you can completely customize how the peripheral works, even emulating existing and at times more expensive chips, especially is this the case with ADCs. The thing is it doesn't have to be a dumb peripheral as it can be doing some real work monitoring I/O perhaps such as MOSFET power stages and shutting them down automatically.
You can even use the PPC as a dedicated high-speed serial port too without dedicating a cog to this task. The PPC can buffer and handshake etc while the Prop can just poll when it wants.
Now, just get your hands on some SILABs chips and have fun.
Run from DOS (or DOSBOX etc):
>ASM PPC
This will assemble the PPC file and generate a binary image called PPC.BIN which is used by the Spin code.
The Spin code is included and all you need to do is compile and load into RAM (F10) and it will program your PPC and reboot the Prop back into it's EEPROM code.
This sample code implements an I2C slave along with automatic ADC conversion and scanning of inputs. There are other commands to read and write I/O and you can completely customize how the peripheral works, even emulating existing and at times more expensive chips, especially is this the case with ADCs. The thing is it doesn't have to be a dumb peripheral as it can be doing some real work monitoring I/O perhaps such as MOSFET power stages and shutting them down automatically.
You can even use the PPC as a dedicated high-speed serial port too without dedicating a cog to this task. The PPC can buffer and handshake etc while the Prop can just poll when it wants.
Now, just get your hands on some SILABs chips and have fun.
Comments
That's quite a trick.
What worries me is the prospect of writing 8051 code, I mean that chip is thirty years old. I remember using it in '84. I feel like I'm stuck in a time warp:)
The ARM chip is about 25 years old too!!! I have never liked 8051 code really but compared to PIC code it is a treat! However, for both of these architectures when they are used for what they were designed for they prove to be very capable.
Here's a sample of 8051 code, as you can see it is very clean and simple:
Good point.
Of course you can still run 16 bit 8086 code on your latest 64bit, multi-core Intel megalith in "real-mode". The 8086 was introduced in 1978.
Then, if you are really keen you can run your 8080 assembly language programs, from 1974, on there as well after you have preprocessed them with conv86 and reassembled for 8086.
I don't mind really, good engineering says if it works, fits the space and budget then go for it.
For anyone wanting to try this that doesn't want to solder the small QFN, you can buy "Toolsticks" from mouser (and elsewhere) for about $10. There are at least a couple in the c8051f33x series.
SOIC14
SOIC20
TSSOP20
QSOP24
Since these integrate easily into a Prop system especially with the in-circuit programming software I have made available I am then planning to release some more source and binary code for these various functions on I2C:
1. Buffered Full-duplex UART
2. Buffered RS485 UART (also supports 9-bit modes)
3. Improved auto-scanning ADC with averaging filters
4. LED drivers with variable brightness and flash.
5. Character LCD driver (easy)
6. PS/2 keyboard and mouse driver
7. RTC (depending upon chip)
8. Boot controller/loader for Prop over radio etc (very useful)
Most of this code I have, I only need to massage it and test it. Bear in mind too that this chip runs at 25MIPS at least and there is probably no reason why it can't be running several of these functions in one.
Any suggestions?
Had I known about it 3 months ago, I would have considered using it.
Thanks for sharing.
There are many advantages to having an intelligent peripheral on the I2C bus. For instance you can have it take control by holding the Prop in reset and loading the EEPROM directly. If you are operating over RS485 or radio links then this is really useful and in fact the only way really that you have any control. All this while the chip is scanning A/D channels and other functions.
I would still like to use the LPC11xx chips but I can see that the development environment could be a little complicated for most, unless of course they simply load binary images.
The important thing to remember is to not get too confused about the CPU core, it's about the functionality and whether it has the capacity to handle it, it does. Do you need an enhanced A/D converter? What about something that handles it's own high speed serial without using another cog? Maybe you just want those PS/2 devices plus some other goodies but you don't have any I/O left. There are even small footprint devices with USB. Well, you just need one I/O pin spare to reprogram the PPC incircuit but even that can be jumpered and shared.
So these functions will just be supplied as a precompiled image to load in using the Spin code provided. Do you want to roll your own? It's not at all hard and the tools are provided.
What I need to know is; do I bother to go to the trouble to polish up these functions for all to use or shouldn't I bother? Which would you like to see first? Is there anything else you need to know?
And once again, this chip is already working in a number of designs, so I have already reaped the benefits of it.