PIC-USB-4550 program does not work

Started by emil_bbb, February 07, 2026, 11:25:50 PM

Previous topic - Next topic

emil_bbb

The board works with the Blinking LED program. However when I program the F4550 with my own software, the software does not work. If I program the F4550 with my K150 the software works. Here is the message that I get when I try to execute the software after programming the F4550 with the PIC-USB-4550 board. https://ibb.co/VW4dDNrZ
What can I do in order to make my software work when I programm the F4550 with the PIC-USB-4550 board ?

LubOlimex

This is a warning that if you download that software to the chip via the bootloader it will disable the bootloader and future upload via the bootloader will not be possible (e.g. you would need to use ISP programmer for subsequent programming).

You have two options:

- Edit the configuration bits in your code so that it doesn't cause problems for the bootloader (change the bits as described in the warning - enable Table Write Protect Boot; enable USB Voltage Regulator; set Oscillator value to HS+PLL, USB-HS).
- Ignore the warnings and break the bootloader; this will require using a programmer in future programming of that chip (this might be useful for security reasons)
Technical support and documentation manager at Olimex

emil_bbb

#2
I have studied the souce code from PIC_USB_4550_BLINKING_LED and I cannot figure out where are those values are set.

//PROGRAMM FOR BLINKING LED
//
// PROCESSOR : PIC18F4550
// CLOCK    : 20MHz, EXTERNAL

#include   <p18cxxx.h>

#define      BUT         PORTBbits.RB4
#define      LED_ON      PORTDbits.RD3 = 1
#define      LED_OFF      PORTDbits.RD3 = 0
#define      TOGGLE_LED   PORTD ^= 0x08
#define      INPUT      1
#define      OUTPUT      0
#define      LED_DIR      TRISDbits.TRISD3
#define      BUT_DIR      TRISBbits.TRISB4

/** V E C T O R  R E M A P P I N G *******************************************/
extern void _startup (void);        // See c018i.c in your C18 compiler dir
#pragma code _RESET_INTERRUPT_VECTOR = 0x000800
void _reset (void)
{
    _asm goto _startup _endasm
}
#pragma code

#pragma code _HIGH_INTERRUPT_VECTOR = 0x000808
void _high_ISR (void)
{
    ;
}

#pragma code _LOW_INTERRUPT_VECTOR = 0x000818
void _low_ISR (void)
{
    ;
}
#pragma code


//Just simple delay
void Delay(unsigned long cntr) {
   while (--cntr != 0);
}

// Main function
void main(void) {
   

   INTCON    = 0x0;         // Disable inerupt
   CMCON    = 0x07;          // Comparators Off
   ADCON1  = 0x06;         // Port as Digital IO
//   RDPU    = 0;         // Disable pull ups
   PORTEbits.RDPU = 0;      // Disable pull ups   
   CCP1CON = 0;          // P1B, P1C, P1D assigned as port pins
   LED_DIR = OUTPUT;      // Led pin as output   
   BUT_DIR = INPUT;      // Button pin as insput


   // loop forever - echo
   while(1) {

      // Toggle led
      TOGGLE_LED;
      // Simple delay
      Delay(50000);
   }   
}

LubOlimex

They are probably not set in the code, but from MPLAB. You can just change them in MPLAB. Search for "MPLAB Viewing and Setting Configuration Bits"
Technical support and documentation manager at Olimex

LubOlimex

It can be added in the code too, probably adding this will lead to success (without warnings):

#pragma config PLLDIV   = 5        // 20 MHz crystal /5 → 4 MHz for PLL
#pragma config CPUDIV   = OSC1_PLL2// CPU clock = 96MHz / 2 = 48MHz
#pragma config USBDIV   = 2        // USB clock = 96MHz / 2 = 48MHz

#pragma config FOSC     = HSPLL_HS // HS oscillator, PLL enabled
#pragma config FCMEN    = OFF
#pragma config IESO     = OFF

#pragma config PWRT     = OFF
#pragma config BOR      = OFF
#pragma config VREGEN   = ON       // USB voltage regulator ENABLED (IMPORTANT)

#pragma config WDT      = OFF
#pragma config WDTPS    = 32768

#pragma config MCLRE    = ON
#pragma config LPT1OSC  = OFF
#pragma config PBADEN   = OFF
#pragma config CCP2MX   = ON

#pragma config STVREN   = ON
#pragma config LVP      = OFF
#pragma config ICPRT    = OFF
#pragma config XINST    = OFF

#pragma config CP0      = OFF
#pragma config CP1      = OFF
#pragma config CP2      = OFF
#pragma config CP3      = OFF

#pragma config CPB      = OFF
#pragma config CPD      = OFF

#pragma config WRT0     = OFF
#pragma config WRT1     = OFF
#pragma config WRT2     = OFF
#pragma config WRT3     = OFF

#pragma config WRTB     = ON       // Boot block write protected (IMPORTANT)

#pragma config WRTC     = OFF
#pragma config WRTD     = OFF

#pragma config EBTR0    = OFF
#pragma config EBTR1    = OFF
#pragma config EBTR2    = OFF
#pragma config EBTR3    = OFF
#pragma config EBTRB    = OFF
Technical support and documentation manager at Olimex