Hid bootloader and 18f2550

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Hid bootloader and 18f2550

Post by be80be » Sun Oct 11, 2015 2:57 am

Why is there no porte there is one pin on that port mclr is on porte I want to use just one button the same button on mclr.
Note 1: Implemented only when Master Clear functionality is disabled (MCLRE
configuration bit = 0); otherwise, read as ‘0’.
2: RE3 is the only PORTE bit implemented on both 28-pin and 40/44-pin devices. All
other bits are implemented only when PORTE is implemented (i.e., 40/44-pin devices).
3: Unimplemented in 28-pin devices; read as ‘0’.

Jerry Messina
Swordfish Developer
Posts: 1246
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Hid bootloader and 18f2550

Post by Jerry Messina » Sun Oct 11, 2015 9:10 am

I don't think it was defined in some of the original mchip files.

If you get a copy of the SystemConvert_v12 download, it has updated device files already generated for you, and it has PORTE defined for the 2550.
From the zip download, copy the contents of the NewInclude and NewIncludeBASIC folders to your swordfish Includes folder.

After that, the following works:

Code: Select all

device = 18F2550
config MCLRE = OFF       // RE3 input pin enabled; MCLR pin disabled

dim b as bit
b = PORTE.3             // RE3 input only... no LAT or TRIS bit needed

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Sun Oct 11, 2015 1:33 pm

Thanks jerry I was playing with this all night and almost got it to work then a new problem popped up for some reason it doesn't like
the
Config
FOSC = HSPLL_HS, // external 24MHz xtal w/PLL
PLLDIV = 5, // PLL prescaler 24/6=4MHz
CPUDIV = OSC1_PLL2, // 48MHz cpu clock (96MHz/2)
USBDIV = 2, // 48MHz usb clock (96MHz/2)
FCMEN = OFF,
IESO = OFF,
PWRT = ON,
BOR = OFF,
BORV = 2,
VREGEN = ON,
WDT = OFF,
WDTPS = 2048,
CCP2MX = OFF,
PBADEN = OFF,
LPT1OSC = OFF,
MCLRE = OFF

Jerry Messina
Swordfish Developer
Posts: 1246
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Hid bootloader and 18f2550

Post by Jerry Messina » Sun Oct 11, 2015 3:01 pm

Burt -

Do you mean it doesn't compile or it doesn't work? I copied those settings and it compiled ok for me...

Code: Select all

device = 18F2550

Config
FOSC = HSPLL_HS, // external 24MHz xtal w/PLL
PLLDIV = 5, // PLL prescaler 24/6=4MHz
CPUDIV = OSC1_PLL2, // 48MHz cpu clock (96MHz/2)
USBDIV = 2, // 48MHz usb clock (96MHz/2)
FCMEN = OFF,
IESO = OFF,
PWRT = ON,
BOR = OFF,
BORV = 2,
VREGEN = ON,
WDT = OFF,
WDTPS = 2048,
CCP2MX = OFF,
PBADEN = OFF,
LPT1OSC = OFF,
MCLRE = OFF

dim b as bit

b = PORTE.3
I just realized... you may have to update your version of MPASM. If you have MPLABX or MPLAB 8.92 installed you can get the files from there.
See the SystemConvert wiki page for details.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Sun Oct 11, 2015 4:10 pm

I maybe doing it wrong I guess can you post the file you compiled.
I changed the sw to mclr and the led to portC 4.
Attachments
18f2550.jpg
18f2550.jpg (227.9 KiB) Viewed 5872 times

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Sun Oct 11, 2015 5:38 pm

I changed it to a 18f4550 and it compiled that still should work on a 18f12550.
I think there the same only the 18f4550 has more pins but the data sheet shows same.
Program Memory
Data RAM
Data EEPROM

Jerry Messina
Swordfish Developer
Posts: 1246
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Hid bootloader and 18f2550

Post by Jerry Messina » Sun Oct 11, 2015 7:15 pm

There is no TRISE for the 2550, so you just read the pin using PORTE.3

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Sun Oct 11, 2015 7:59 pm

How big is the hid bootloader I'm using 4036 program bytes.
I posted the errors I got. I know you can see the pic your swordfish must be different then mine.
I added the files you posted and I only got the trise error.

User avatar
octal
Registered User
Registered User
Posts: 584
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Re: Hid bootloader and 18f2550

Post by octal » Sun Oct 11, 2015 10:03 pm

Depending on the device sizen, portE is implemented differently on PIC18Fxx50.
On 28 pin devices, you have only RE3 implemented and it's always input, so you **don't** have any TRIS register associated to this port. You don't even need to configure it as input since it's always input. You simply read the PORTE.3 bit directly.

You can check the datasheet.
Attachments
dev40.png
dev40.png (26.36 KiB) Viewed 5858 times
dev28pin.png
dev28pin.png (11.31 KiB) Viewed 5858 times
table.png
table.png (50.56 KiB) Viewed 5858 times

Jerry Messina
Swordfish Developer
Posts: 1246
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Hid bootloader and 18f2550

Post by Jerry Messina » Sun Oct 11, 2015 10:09 pm

How big is the hid bootloader I'm using 4036 program bytes
That sounds about right for a 2550. You want it to be < 4096.

I haven't tried building the bootloader, just checking that the 2550 compiles ok.

If you're getting TRISE errors, then check the file where you're using the RE3 input.
If there's a statement like 'input(PORTE.3)' then remove it... like octal says PORTE.3 is always an input,
and the microchip files don't define TRISE or LATE for the 18F2550, so you can't change its direction

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Sun Oct 11, 2015 10:24 pm

LOl Im using it for the reset button think that's input, Works fine on start usb using there bootloader but I had to dig up a 8 mhz crystal.
And the board is done made with a 20 mhz crystal. It compiles fine if I don't use that pin but I done made my board to use it to reset the pic and was going to use it for more. But there bootloader works great with swordfish. Guess I'll replace the crystal.

I didn't use it for output I know what it can be used for. Start usb uses it to go into program mode. Same Idea I have then you can use it as a button for input but my swordfish don't like that LOL. I'm sure your swordfish has changes I don't have.

All I did was change the program button on the UBW_2553 bas from portC to that mclr. And changed the name to UBW_2550.bas I went back and changed the program pin to what it had and it works ok it just don't like RE3 I guess but the two bootloaders I use worked fine with it. I run the code I made with swordfish it runs fine on the start usb bootloader.

Then I started getting VIN and PIN problems too had to remove all the hiding hid devices. Got to watch that on windows 10 it don't like to let you reinstall I remove my pickit2 one it doesn't tell who the driver is by just a pid and VIN number and microshit lol.

Jerry Messina
Swordfish Developer
Posts: 1246
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Hid bootloader and 18f2550

Post by Jerry Messina » Mon Oct 12, 2015 9:47 am

... but I had to dig up a 8 mhz crystal. And the board is done made with a 20 mhz crystal
You should be able to use your 20MHz crystal just fine... the config you posted seems right for that

Code: Select all

config
    PLLDIV = 5,         // Divide by 5 (20 MHz oscillator input)
    CPUDIV = OSC1_PLL2, // [Primary Oscillator Src: /1][96 MHz PLL Src: /2]
    USBDIV = 2,         // USB clock source comes from the 96 MHz PLL divided by 2
    FOSC = HSPLL_HS,    // HS oscillator, PLL enabled (HSPLL)
That should give 48MHz to the USB section and 48MHz for the CPU clock.
All I did was change the program button on the UBW_2553 bas from portC to that mclr
Ok, so in your new UBW_2550.bas file you need to comment out the 'input(INPUT_SW)' statement.
That's the one trying to set TRISE.3, and there's no TRISE register for the 2550, something like this:

ubw_2550.bas:

Code: Select all

// switch is on MCLRN/RE3 pin
public dim INPUT_SW as PORTE.3      // sw S2 (marked PRG) w/ext 10K pullup

//
//-----------------------------------------------------------------------------
// userInit() - setup IO pins and other req'd regs
//-----------------------------------------------------------------------------
//
public sub userInit()

  #if (_device = 18F2553)   ' some ubw versions use a different chip
    ADCON1 = %00001111      ' all digital (disable A/D on all pins)
    CMCON = %00000000       ' disable comparators
    CVRCON = $00            ' and turn off reference
  #endif

    // init leds & switch
    low(LED1)
    low(LED2)
    
    // comment out the following for PORTE.3 and 28-pin devices
    // the pin can only be an input, and there is no TRISE register
    'input(INPUT_SW)
end sub

and do the same in the file SF HIDbootloader143\userlib\userio.bas

Code: Select all

//
//-----------------------------------------------------------------------------
// UserExit is called before exiting the loader and running the application
//-----------------------------------------------------------------------------
//
public inline sub UserExit()
    // << add code to restore any hardware registers to their power on state >>
    // << comment out code if not used >>

    input(STATUS_LED)

    // comment out the following for PORTE.3 and 28-pin devices
    // the pin can only be an input, and there is no TRISE register
    'input(BOOTSELECT_IN)
end sub

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Tue Oct 13, 2015 10:44 pm

I had to make more changes then what you posted but thanks that pointed to what was killing the show.
But after playing with the mikroC hid bootloader I like it. It's supper fast I mean fast. And it works great with swordfish.
I just press the mclr pin let go and it finds the pic load the hex in there app and press program and it's loaded and starts running.

I made a board that using the arduino layout it works great.

Jerry Messina
Swordfish Developer
Posts: 1246
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Hid bootloader and 18f2550

Post by Jerry Messina » Wed Oct 14, 2015 11:29 am

I had to make more changes then what you posted
Just for my own information do you remember what else you had to change?

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Re: Hid bootloader and 18f2550

Post by be80be » Wed Oct 14, 2015 11:20 pm

It's calling this so when you commit it out as input you get errors

Code: Select all

Public Inline Function UserBootselect() As Boolean
    // << add code to read switch or IO pin >>
    // << just return false if not used >>
   result = false              // run application
    
    If (BOOTSELECT_IN = 0) Then     // read low-active IO pin
       result = true               // stay in bootloader
   EndIf
End Function

End Module

Post Reply