• Pic® Basic


  • VBLOADER

    By Jonathan Walker

    The VBLOADER is a small Visual Basic program that I created to simplify the upgrading of the program code within a PIC® Microcontroller when using the bootloader.

    What is a bootloader?

    A bootloader is a special piece of code that usually occupies the last 256 Bytes of a Microcontrollers program memory. It has the capability to self-program its own program memory. The PIC® 16F876 is one such device that has the required instructions and hardware to do this.
    In order for you to use the bootloader you must first program a device with the bootloader source code. These bootloaders are usually small in size and generally occupy less than 256 bytes of program memory (So you don’t loose much space). You will however have to have a separate bootloader for each different configuration setting of the PIC®. The reason is because the configuration bits (oscillator, WDT, power-up timer etc) cannot be altered during general execution of the program code. These must be set at the programming stage. The clever bit of the bootloader is the fact that the main code (your program) is passed to the bootloader code via a RS232 link. The bootloader code then programs your code into the devices program memory.
    You can still use the serial port in your code, the only thing that you must not allow is any serial information coming into the device when it is first powered up (well apart from the bootloader program on the PC). This is due to the fact that the first instruction in the PIC® (This is part of the bootloader source program) jumps to the bootloader that resides in the last 256 bytes of the microcontroller. The bootloader then monitors the serial port for activity for a short period of time. If it receives no serial data then it will jump to your code. If it receives communication from the PC bootloader program then it will execute the bootloader and self program the device.

    Why should I use one?

    Speed… Using a bootloader for development and cases where serial ports are not used (or you know what you are doing and can control the external serial data flow) is the fastest way of getting your code running.
    Yes you can program ICSP but this is slower and is not as simple to use as the bootloader and needs a programmer capable of ICSP.
    If you use PROTON+ from Crownhill Associates you have the option to use the bootloader from within the compiler. This means that you can compile the code and have it running on your application board in around 5 seconds! That’s pretty fast in anyone’s book

    How do I use one?

    Buy a compiler or bootloader source code. By obtaining a compiler with free bootloaders you get more bangs for your buck. Proton is around £65 and the Pro version, PROTON+ is £125. You will find a host of bootloader source files in one of the directories.
    Please note that Proton and Proton+ have been superseded by the Proton Development Suite
    You obviously need a programmer! You can make one of these or you can buy a PIC® with a bootloader already programmed into it.
    Your development board should have a RS232 – TTL converter IC or discrete level shifter circuit. This can be integrated onto the board or in my case I have a separate unit and a connector on my development board. Four pins (5V,0V,RX,TX,) are connected to your microcontroller (serial port is RC6 and RC7 on the 16F876/877). The other end has a 9 way d-type that connects a cable to the PC. This converter board is powered from your development board.
    How to build such a converter.


    Connect your development board and RS232-TTL converter to the PC serial port. Write your code, and download it using the bootloader.
    The beauty of having a serial port as well is that you can use a terminal program (A good one is supplied free in PROTON+) to debug your code , so no need for an LCD.

    The VB application.

    I am not a VB coder and I am sure that my code (7.6MB) is not at all the most compact solution. But it’s a start. 5 hours ago I had never used VB and now I still can’t use it. Well, a little.
    I had a particular application where I was required to design a generic circuit board that had many functions. It could be an analog data logger, a temperature sensor (8 channel –55 to +180), a programmer, a current monitor or DVM etc. The list was endless, so I put everything onto this one generic design. I therefore needed many different programs to run on it. The users of this board had no knowledge of microcontrollers and PIC® programmers and would find it very confusing to program them due to all of the options so I needed a safe and easy option.
    I therefore developed this application so they could program the board on their own PC with minimal effort. This way they could also extract data using the terminal program.
    All I had to do was initially load up a bootloader and code all of the programs with the same configuration settings (oscillator frequency and watchdog etc).
    Simple. All the user has to do is find my universal logger and plug it into their pc and run the VB application. On the application I have limited the number of choices to 3 but you can develop this to any number.
    The only problem I have encountered is if you have a directory path name with a space in it. (For example C:\program files) it will not pass the hex file to it. I don’t know why it happens but maybe you can work it out and tell me. To get round it, don’t have a space. When you install it, use C:\JWBOOT and not C:\program files ,then place your hex code in a directory that has no spaces in the path, such as C:\JWBOOT.
    If you find this useful send me a Email jonwmobile@hotmail.com or post a reply on the picbasic forum in PROTON+. I am JONW by the way.
    Finally, TERMINAL and BOOTLOAD belong to LES JOHNSON and CROWNHILL. If you are an unregistered user and like it, then please consider purchasing the compiler.
    Regards
    Jonathan Walker

    About the Proton Compiler

    Crownhill's Proton Plus Compiler is a part of the Proton Development Suite - A suite of British-developed applications enabling fast development of PIC® micro's using the PIC® BASIC Language.
    For more information on the Proton Development Suite, please visit www.picbasic.org
  • Recent Activity

    towlerg-21522

    UltraEdit adaption.

    Thread Starter: johngb

    I didn't know where to post this thread but as I guess this section is one of the most viewed I am posting here. After Les mentioned UltraEdit on...

    towlerg Today, 00:52 Go to last post
    joesaliba-353

    Correct use of bit names

    Thread Starter: joesaliba

    So I have the following: - Symbol RBIF = INTCON.0 ' Port B Interrupt-On-Change (IOCx) Interrupt Flag bit Symbol INT0IF = INTCON.1 ' INT0...

    joesaliba Yesterday, 17:20 Go to last post
    xldaedalus-432

    Coming out of an ISR

    Thread Starter: johngb

    I am adding error handlers to my P-RTOS24 and want to handle the situation where a task hangs and blocks returning to the OS. To do this I have a...

    xldaedalus Today, 08:33 Go to last post