Hid bootloader and 18f2550
Moderators: David Barker, Jerry Messina
Hid bootloader and 18f2550
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’.
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’.
-
- Swordfish Developer
- Posts: 1487
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Hid bootloader and 18f2550
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:
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
Re: Hid bootloader and 18f2550
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
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
-
- Swordfish Developer
- Posts: 1487
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Hid bootloader and 18f2550
Burt -
Do you mean it doesn't compile or it doesn't work? I copied those settings and it compiled ok for me...
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.
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
See the SystemConvert wiki page for details.
Re: Hid bootloader and 18f2550
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.
I changed the sw to mclr and the led to portC 4.
- Attachments
-
- 18f2550.jpg (227.9 KiB) Viewed 14388 times
Re: Hid bootloader and 18f2550
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
I think there the same only the 18f4550 has more pins but the data sheet shows same.
Program Memory
Data RAM
Data EEPROM
-
- Swordfish Developer
- Posts: 1487
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Hid bootloader and 18f2550
There is no TRISE for the 2550, so you just read the pin using PORTE.3
Re: Hid bootloader and 18f2550
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.
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.
Re: Hid bootloader and 18f2550
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.
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 (26.36 KiB) Viewed 14375 times
-
- dev28pin.png (11.31 KiB) Viewed 14375 times
-
- table.png (50.56 KiB) Viewed 14375 times
-
- Swordfish Developer
- Posts: 1487
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Hid bootloader and 18f2550
That sounds about right for a 2550. You want it to be < 4096.How big is the hid bootloader I'm using 4036 program bytes
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
Re: Hid bootloader and 18f2550
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.
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.
-
- Swordfish Developer
- Posts: 1487
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Hid bootloader and 18f2550
You should be able to use your 20MHz crystal just fine... the config you posted seems right for that... but I had to dig up a 8 mhz crystal. And the board is done made with a 20 mhz crystal
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)
Ok, so in your new UBW_2550.bas file you need to comment out the 'input(INPUT_SW)' statement.All I did was change the program button on the UBW_2553 bas from portC to that mclr
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
Re: Hid bootloader and 18f2550
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.
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.
-
- Swordfish Developer
- Posts: 1487
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Hid bootloader and 18f2550
Just for my own information do you remember what else you had to change?I had to make more changes then what you posted
Re: Hid bootloader and 18f2550
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