Programming a PIC microcontroller from a Propeller 1
JimFouch2
Posts: 26
in Propeller 1
I have a product I'm bringing to market. In the design, I'd like to give my customers the ability to upgrade the Propeller with new firmware simply using a Micro USB cable and a custom PC app. I think I should have no issues doing that part.
In my design, I plan on using a PIC18F27K42 micro controller. This PIC will control a graphical OLED and do some other functions for the device. Communications between the PIC and Prop will be through a dedicated UART (Not the UART/USB pins on the Prop). The Propeller will be the main application and will need firmware updates on a semi-regular basis.
I'd like to have the option to update the PIC. These are normally programmed using an ICD or PicKit. I would prefer to not require my customers to need a programmer.
From looking at the specs of the PIC, it looks like it's somewhat straight forward. You need to apply a programming voltage (5V, I think) to the MCLR/Vpp pin and take the ICSP CLK & DAT lines low. Then it should just be a process of sending down the new program and verifying the data.
My initial design will use a Parallax FLiP and use it's on board USB connector to communicate with my PC App for both sending down user data and reprogramming the FLiP with new firmware.
My question is, how hard would it be to allow the Propeller pass through a new program while it's connected to my application? I understand, I need to write the PC App and the ability.
From looking at a PicKit, it looks like it's just another PIC processor, so I think the Propeller, should also be able to do this.
In my design, I plan on using a PIC18F27K42 micro controller. This PIC will control a graphical OLED and do some other functions for the device. Communications between the PIC and Prop will be through a dedicated UART (Not the UART/USB pins on the Prop). The Propeller will be the main application and will need firmware updates on a semi-regular basis.
I'd like to have the option to update the PIC. These are normally programmed using an ICD or PicKit. I would prefer to not require my customers to need a programmer.
From looking at the specs of the PIC, it looks like it's somewhat straight forward. You need to apply a programming voltage (5V, I think) to the MCLR/Vpp pin and take the ICSP CLK & DAT lines low. Then it should just be a process of sending down the new program and verifying the data.
My initial design will use a Parallax FLiP and use it's on board USB connector to communicate with my PC App for both sending down user data and reprogramming the FLiP with new firmware.
My question is, how hard would it be to allow the Propeller pass through a new program while it's connected to my application? I understand, I need to write the PC App and the ability.
From looking at a PicKit, it looks like it's just another PIC processor, so I think the Propeller, should also be able to do this.
Comments
The Prop will only act as a conduit from the PC App, which will have the HEX file to programmed into the PIC.
I think my first step is to use a scope and logic analyzer and see how the PicKit3 does it. That will probably get me started in the right direction.
Just not sure how complicated the process is. A normal HEX file has addresses on each line where it wants the data from that line to be placed. Just need to see how that works.
This is the PIC18(L)F26/27/45/46/47/55/56/57K42 Memory Programming Specification, straight from the Microchip website.
http://ww1.microchip.com/downloads/en/DeviceDoc/40001886B.pdf
Google finds a Microchip bootloader generator, that sounds useful
https://www.microchip.com/promo/8-bit-bootloader
Many MCUs come with bootloaders pre-installed, and some have them in ROM. Not sure about PIC18's ?
http://ww1.microchip.com/downloads/en/DeviceDoc/39644l.pdf
It precludes having to use a resident bootloader. It's best to choose a PIC that doesn't require a high-level Vpp and that can be programmed while Vdd is 3.3V. Barring that, I would recommend switching to the AVR family of microcontrollers. Their in-circuit programming is quite simple.
-Phil
Another feature you can incorporate is setting and tracking serial numbers which can report back to a PC when it is plugged in again.
Is there a reason that you need a PIC to control hardware such as an OLED?
Just using the PIC because it cheap and it will offload all the logic to do text and graphics from the Propeller so it can focus on the actual application code.
I also need to be able to read ADC. It's funny that a MCP3208 12 bit ADC costs like $3-$4 and only does ADC, yet a PIC18F27K42 does ADC and have 128KB FLASH & 8KB RAM and can be had for $2. lol
So this is is kind of killing 2 birds with one stone.
I also have a pretty extensive library for graphics LCD/OLED I have already build in the PIC for other projects.
I also plan on storing several fonts and images in the PIC that won't have to be stored or managed in the Propeller.
https://sites.google.com/site/thehighspark/arduino-pic18f
I'd be interested in any progress you make, could be an interesting addition to the JTAGulator base. I've been working on opening xsvf files from SD to program coolrunner ii cplds.
Thanks for the info.
I was looking at possibly using a bootloader, but have decided against it. I'm going to do what I need to have the Propeller do the programming like the PicKit does. This way, I won't have to touch the PIC to put a bootloader on it. I can simply flash the Propeller, then have it flash the PIC. I will only have a single external USB connector. This way, when I get the device from the manufacturer, I can flash the device, w/o having to disassemble it. I don't want the manufacturer to have my program. I'd rather control that process myself.