PDA

View Full Version : 18F4550.BAL, PBPL, and USB



rsocor01
- 8th August 2010, 01:11
Hi all,

There are two versions of the file 18F4550.BAL. One is for USB use and the other one is for PBPL use. The two files are shown in the next thread (thank you DT).

http://www.picbasic.co.uk/forum/showthread.php?t=10409&p=68949#post68949

I'm working in a project that combines PBPL and USB. The problem that I have is that if I use the 18F4550.BAL PBPL version then I get the following errors


ERROR: Macro USBINIT? not found in macro file.
ERROR: Macro USBSERVICE? not found in macro file.
ERROR: Macro USBIN?CBBL not found in macro file.
ERROR: Macro USBOUT?CBBL not found in macro file.

But, if I use the USB file version then I get errors like


ERROR: Unable to fit variable Var_Name

where Var_Name is a LONG variable. I worked out a "fix" for this problem by modifying the 18F4550.BAL file the following way


BANKA $0000, $005F
BANK0 $0060, $00FF
BANK1 $0100, $01FF
BANK2 $0200, $02FF
BANK3 $0300, $03FF
BANK4 $0400, $04FF
BANK5 $0500, $05FF
BANK6 $0600, $06FF
BANK7 $0700, $07FF
EEPROM $F00000, $F000FF
'LIBRARY "PBPPI18L"
LIBRARY "PBPUS18L"

include "PIC18EXT.BAS"

PORTL VAR PORTB
PORTH VAR PORTC
TRISL VAR TRISB
TRISH VAR TRISC

include "PBPPI18L.RAM"


So far, my setup is been working fine. However, the PIC uses BANK 4, 5, 6, and 7 for the USB module, so by me enabling these BANKS I suspect I'm doing something horribly wrong. The USB interface is been working fine like I said before, but this might be pure luck.

Is there a better fix for this PBPL and USB problem? If I only disable BANKS 4 and 5, would that be a better fix? Why is the "EEPROM $F00000, $F000FF" line disabled in the original files?

Thank you all for your help.

Robert

Darrel Taylor
- 8th August 2010, 01:53
Hi Robert,

The original USB files (prior to 2.60), reserved all of the USB memory for USB.
But it's not very often that anyone would ever use all of it, so in PBP 2.60 the useage was reduced to only 1 BANK.

For 18F4550's, it's BANK4.

In your file for PBP 2.50prior, you must at least comment out the BANK4 line.
Or PBP variables will be assigned to the same locations as USB buffers.

But uncommenting the others will free up quite a bit of RAM space.

hth,

rsocor01
- 8th August 2010, 04:30
Thank you Darrel,

I will comment out the BANK 4 line like you said and will get back with the results. From the attached figure I can see that there is still space in BANK 4 for USB data transfer like you said, unless Ping-Pong Buffers on all EPs is used. I have a very vague idea of what this Ping-Pong issue means, but do you know if EasyHID uses this Ping-Pong Buffers on all EPs?

Also, do you know why the "EEPROM $F00000, $F000FF" line is commented out in the original 18F4550.BAL files?

Robert

4680

Darrel Taylor
- 8th August 2010, 17:02
Nope, PBP doesn't use Ping-Pong buffers.
So EasyHID doesn't either.

I think the commented EEPROM line is a carry over from earlier versions, and is handled in the compiler now for 18F's.
All the other 18F .bas/.bal files have the EEPROM commented.
The newer chips don't even have an EEPROM line in their files.

rsocor01
- 9th August 2010, 04:06
Darrel,

Thank you. I commented out the BANK 4 line and it compiled without any errors. Everything seems to be working fine. Again, thank you for your help.

Robert