Shop OBEX P1 Docs P2 Docs Learn Events
Programming a PIC microcontroller from a Propeller 1 — Parallax Forums

Programming a PIC microcontroller from a 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.

Comments

  • Sounds like an interesting project. So you want to use the prop to compile a hex file and load to the Pic is that correct.
  • Put a serial port bootloader on the PIC. Use an IO pin to signal to the PIC that it should enter the bootloader.
  • DigitalBob wrote: »
    Sounds like an interesting project. So you want to use the prop to compile a hex file and load to the Pic is that correct.

    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.
  • kwinnkwinn Posts: 8,697
    Using a P1 to program a PIC should be relatively easy to do. I have used a P1 to download from and program a variety of 27xx chips. It did require some additional circuitry to go from 3.3V to 5V, and a circuit to control the programming voltage. Hardware for programming the PIC should be simpler, although the software might be more difficult.
  • JimFouch2,

    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
  • jmgjmg Posts: 15,140
    JimFouch2 wrote: »
    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.
    If you already have a serial link, you could look at Serial Bootloaders ?
    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 ?
  • I think this is the document you want:

    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
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-02-06 21:15
    Most PICs use the old clock and data and Vpp to program and I have built my own programmers for these and other micros etc since the early days, as well as using PicKits too. The code is straightforward enough to program and verify a PIC but normally for production programmers I run these standalone and only ever connect to a PC to update the PIC firmware image. It is so much simpler to load up the programmer once and then you only need to attach the programmer long enough to press the program button and over a couple of seconds have some LEDs tell you the progress (or even a Neopixel). Just power the programmer from the target circuit and your software can even detect the PIC on power-up and program it if it is blank or earlier firmware etc. Even easier.

    Another feature you can incorporate is setting and tracking serial numbers which can report back to a PC when it is plugged in again.


  • JimFouch2,

    Is there a reason that you need a PIC to control hardware such as an OLED?
  • I'm sure this is possible. In the mid 90's I wrote a QuickBasic program to do this through the parallel port. I think the thing you will first run into is speed. PIC's are much bigger these days, and the time to download a program could be substantially longer. The way around this will be to pay close attention to the timing requirements which will vary between different flavors of PIC.
  • Genetix wrote: »
    JimFouch2,

    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.
  • This should totally be doable. I needed to program a pic 18F and was able to find an Arduino project that only needed slight modification to program my chip. The code was really simple and while digging around I thought the propeller would have no problem doing this. The PC program was a bit wonky iirc but if you were developing your own app then should not be an issue.

    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.
  • cheezus wrote: »
    This should totally be doable. I needed to program a pic 18F and was able to find an Arduino project that only needed slight modification to program my chip. The code was really simple and while digging around I thought the propeller would have no problem doing this. The PC program was a bit wonky iirc but if you were developing your own app then should not be an issue.

    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.
Sign In or Register to comment.