PDA

View Full Version : usb to serial and back on the fly with ucase$



f_lez
- 29th October 2009, 20:12
Ok I was thinking of a little project to test the old grey cells and to finally how to learn how to use USB as i am planning to need it soon, and sooner jump into a big project this seems easier....


Set usb on the pic to appear to windows as a virtual com-port


if available, read a character, from the virtual com-port, convert it to upper case, and then output it at 9600 via the hwuart....

and....

if available, read a character, from the hwuart , convert it to upper case, and then output it at 9600 via the virtual com-port


continue till the worlds end.

Now its all simple when written down, and i can easily achieve this if it was using the hwuart and a swuart, but i am lost with the usb side.

I think i'm in the same boat as alot of people on this, so can we do this simply, if usb is such a thing.....

I know there are lots of easy this and that and HIDeous things around, but the keyword is simple.....

Got a spare 18f2550 and a 4mhz crystal here i think may be just the ticket

f_lez
- 30th October 2009, 01:26
ok had a look at MCS and easyhid, tried to compile the output it generated, but i got an error that pbppic18.lib could not be found.


i added a line near the top, include ''pbppic18.lib'' but now get an error a redefinition of label of [ifndef]

never easy is it, even when its called easy.....

f_lez
- 30th October 2009, 17:20
Ok i found the easy cdcusb demo thingy....(technically minded me)

i eventually got it all copiling without errors once i fixed the paths in the 'incs'

but....

now i have another issue...

this is a segment of my test code




portb=16+8
pause 1000
portb=8+1
pause 1000
USBInit
portb=8






It gets to ubinit with all being fine, then the lights go out, and thats the end of it.....

if it was waiting at usbinit or stuck at it i would expect the lights to stay on...


anyone know why that happens, windows does nothing either.

Darrel Taylor
- 30th October 2009, 17:40
It looks like the External USB Transceiver pins are active. (VPO VMO etc.)

Have you changed the UCFG register?
You should not.
<br>

f_lez
- 30th October 2009, 18:53
It looks like the External USB Transceiver pins are active. (VPO VMO etc.)

Have you changed the UCFG register?
You should not.
<br>

it has a ucfg register? i just downloaded the usbcdc demo and compiled it, when i said i fixed the incs i meant the inc issue with the 18f2550 fuses and the invalid path in one of the incs i found.



by flashing the leds on portb etc i know i am running internally at the right speed so my clock divs are ok.

all i have is pic on a board with leds on the ports and a usb connector, nothing fancy, was hoping to achive success with the KISS principle..

precompiled stuff seems to work, i used this board about two years ago with the simple usb demo, but i need to make it do serial...

I did just find another path {c:\pbp\pic¬1.47\} that i need to edit but the phone just went and i have to go drive someone shopping!

thanks for the reply, i'll update when they stop dragging me back to the real world

f_lez
- 30th October 2009, 21:40
ok now i want to scream at it..........




buffer Var Byte[16]
cnt Var Byte
flash var byte

LED0 Var PORTB.0
LED1 Var PORTB.1
LED2 Var PORTB.2
LED3 Var PORTB.3
LED4 Var PORTB.4

CMCON = 7 ; turn off comparators
ADCON1 = 15 ; turn off analog inputs

define OSC 48

trisa=0
trisb=0

high led0
high led1
high led2
high led3
high led4

pause (1000)
low led4
pause (1000)
low led3
pause (1000)
low led2
pause (1000)
low led1
pause (1000)
low led0
pause (1000) ; end of the pretty countdown


portb=9
pause 1000
; usbinit
portb=8
pause 1000 ; never gets to here if i un-rem usbinit
portb=16

; Wait for USB input
idleloop:
; USBService ' Must service USB regularly
; cnt = 16 ' Specify input buffer size

if flash=0 then
portb=1
flash=1
else
portb=0
flash=0
endif
;
; USBIn 3, buffer, cnt, idleloop

pause 1250
goto idleloop



with the usb bits rem'd out, the led's flash as expected, as soon as i un=rem usbinit, it hangs at usbinit

f_lez
- 30th October 2009, 23:28
actually, after displaying '9' on portb, it goes immeditaly to showing '1', and i mean immediate, no one second pause displaying '8'

to get to '1' it must pass '8', but then if it got to '1', it should flash between '1' and '0'.........and it does not - ant that last pause is 125 not 1250........

now i am confused

Darrel Taylor
- 31st October 2009, 01:19
I see that you changed the label Loop to IdleLoop.

Was that because you have PBP 2.60?

If so, you'll need to make some changes.
USB is different now.

ADDED: If it is 2.60 ... Check out this ...
http://www.picbasic.co.uk/forum/showthread.php?p=80301#post80301
<br>

f_lez
- 31st October 2009, 12:19
I see that you changed the label Loop to IdleLoop.

Was that because you have PBP 2.60?

If so, you'll need to make some changes.
USB is different now.

ADDED: If it is 2.60 ... Check out this ...
http://www.picbasic.co.uk/forum/showthread.php?p=80301#post80301
<br>


no it was idleloop as down loaded from here
http://www.melabs.com/resources/samples/xusb/pbp/usbcdc.bas


' USB sample program for PIC18F4550 CDC serial port emulation

' Compilation of this program requires that specific support files be
' available in the source directory. You may also need to modify the
' file USBDESC.ASM so that the proper descriptor files are included. For
' detailed information, see the file PBP\USB18\USB.TXT.

buffer Var Byte[16]
cnt Var Byte

LED Var PORTB.0

Define OSC 48


USBInit
Low LED ' LED off

' Wait for USB input
idleloop:
USBService ' Must service USB regularly
cnt = 16 ' Specify input buffer size
USBIn 3, buffer, cnt, idleloop

' Message received
Toggle LED

buffer[0] = "H"
buffer[1] = "e"
buffer[2] = "l"
buffer[3] = "l"
buffer[4] = "o"
buffer[5] = " "
buffer[6] = "W"
buffer[7] = "o"
buffer[8] = "r"
buffer[9] = "l"
buffer[10] = "d"
buffer[11] = 13
buffer[12] = 10
buffer[13] = 0

outloop:
USBService ' Must service USB regularly
USBOut 3, buffer, 14, outloop

Goto idleloop ' Wait for next buffer



using 2.47

I changed the chip type to 2550 in MCS, copied the usb support files into my pbp directory, and compiled..


hey prestnot......

so added a few led statements and lost more hair, and i'm still here, its not going to win the war, battles its winning on but i'm not keeping count....

is there any fuses that may stop usb working ?

maybe i have something wrong in that area because the basic programs so short theres not a lot of possibility of error, so thinking its something thats not to be seen going on, or not going on.

Darrel Taylor
- 31st October 2009, 19:27
I changed the chip type to 2550 in MCS, copied the usb support files into my pbp directory, and compiled..
Did you read the USB.TXT file?
They don't go in the PBP folder. They go in your project's folder.
Now you've messed up the .bas files for all the USB chips, and will have to restore them from the CD or a backup.

Did you modify the USBDESC.ASM file to point to the CDC descriptors?

Do you have a .22uF or higher capacitor on VUSB?

Are your configs set for a 4Mhz crystal, with USB regulator enabled?

ASM
__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
ENDASM


And restore the program back to what it was originally (download it again).
It won't work the way you've modified it.
<br>

f_lez
- 1st November 2009, 12:05
Did you read the USB.TXT file?
They don't go in the PBP folder. They go in your project's folder.
Now you've messed up the .bas files for all the USB chips, and will have to restore them from the CD or a backup.

Did you modify the USBDESC.ASM file to point to the CDC descriptors?

Do you have a .22uF or higher capacitor on VUSB?

Are your configs set for a 4Mhz crystal, with USB regulator enabled?

ASM
__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
ENDASM


And restore the program back to what it was originally (download it again).
It won't work the way you've modified it.
<br>


going to do a full wipe and start afresh.

I take it i can use latest mpasm with me old 2.46, or should i get old mpasm? i'll go with the latest one for now.

hell i even spent most of yesterday trying 'other products' but by last night i gave up, too many buttons and options and built in this and that i could not see what it was doing!

f_lez
- 1st November 2009, 12:45
Ok, I'm going slowly and step by step now and leaving my educated guesses where they belong.....


pbp2.46 from cd to c:\pbp

pbp2.46a patch from melabs website link

mpasm 5.20 from melabs website link, to c:\mpasm

MCS installed and pointed to pbp and mpasm

New project director c:\pic2009\usbtest091101\

All files from c:\pbp\USB18\ to project directory

edit usbdsc to:



; This file contains an include for the application specific
; USB descriptors. Include only ONE of the following or add
; your own for your own project.

; include "MOUSDESC.ASM" ; USB descriptors for mouse demo
; include "JADESC.ASM" ; USB descriptors for Jan Axelson's demo
include "CDCDESC.ASM" ; USB descriptors for CDC demo



@this point i get the config has been depreciated but with the recession what hasnt.....

I'l go burn this and see what happens

ScaleRobotics
- 1st November 2009, 12:48
I take it i can use latest mpasm with me old 2.46, or should i get old mpasm? i'll go with the latest one for now.


You can only use the newest MPASM with PBP v 2.60. For any earlier version, MPASM 8.15a (or earlier) is the way to go. http://melabs.com/downloads/mplab_v815a.zip

f_lez
- 1st November 2009, 13:05
Thanks, but i'm on 246, but it seems ok with mpasm5.2


Fuses, mine are a little different , i'm on 20mhz so i have these in the inc



__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L




At the top of the program, right after define OSC etc i put a high led pause 1000 low led and led lights for 1 second so looks ok

On the dev board/programmer it lights 4 seconds, but that does have a 4mhz, i should change devboard/prototype to same crystal really

not detected by windows, back on dev board if i switch portC led's on i get a good light on RC3 and a dimmer one on RC5, if i poke a shaky finger at rc4, rc5 flickers, so looks like its running.


...oh hang on BRB, theres a compiler error about overwriting previous contents, could have been there a while as its down bottom of screen and you have to scroll past the depreciated warnings

Back, set config1 more than once...
fixed, no improvement

f_lez
- 1st November 2009, 14:03
Ok this has been a voyage of discovery, DT has once again proved he knows what he's on about with these black squiggly caterpillar shaped things and is a patient man, although he could have been throwing things at the screen reading my meanderings i dont know..

Anyhow, I thank him, and respect his advice, and by following it, I have won the war.


So, I now pass on my words of wisdom learned form this, and i also offer my hex for others following the path.


1) if nothing seems to be making sense - reinstall PBP and MPASM and your text/source editor IE MCS

2) RT*F*M ! TWICE - I copied files into the wrong places and ruined it all, had to go back to step 1, you may too, we all do from time to time, no matter how much you tell yourself you dont need to, for the sake of 15mins, DO IT

3) Check your HW - the USB bus is a funny old thing, find one of the usual example diagrams, and wire it that way, dont add anything, dont be a genius and take something off, do it as it shows, exactly as it shows, the three important connections are D+,D- and the VUSB capacitor, do not be having bright ideas, just build as it is in all the diagrams, its the same in them all for a reason, that way works.

4) Use a standard crystal size like 4mhz or 20mhz if possible, reason being you may be lucky and find someone has posted some pre-compiled code for your chip, then you can just burn that to test your hardware, thats one part of the puzzle completed, if it does not work then, fix your hardware, if it works and your code does not, fix your code, you win half the battle if you can find some code to help you


5) Dont give up, dont expect immediate help, it can take a few days for someone to remember something that may help you, just wait patiently and do something else in the mean time


I hope my blundering efforts to get USB working give you hope, I managed it, I'm not the best at this by a long way, I got my help and I'm a happy bunny, now I'm going to try and help back, by posting some simple working hex so if you are having problems, you can test your hardware before blaming your software....

Heres another good place to start
http://www.picbasic.co.uk/forum/showthread.php?t=5806

f_lez
- 1st November 2009, 14:17
Pic 18f2550 USB-CDC 4Mhz

When burned to pic and built up on a board fit led to portb.0 it will flash twice and then init usb connection

LED should be on for one second and off one second, if not check your crystal is right and your programmer has not changed any of the fuse settings to a different pll/cpu div

This is for a 4mhz crystal to the pll (pll/1) and cpudiv=1(pll/2) which is 48mhz clocking



:020000040000FA
:1000000022EF00F0036A026EFF0E0226D8A003263C
:10001000D8A01FEF00F0030E016EE70E02D8F4D750
:10002000016AFD0F006EFF0E00D001D00026040013
:1000300000D000D0D8A00126D8A01200F7D7000128
:10004000040012000CEF04F0120C010C100C010C57
:10005000020C000C000C080CD80C040C0A0C000C50
:10006000000C000C010C020C030C010C7000700061
:10007000090C020C430C000C020C010C020C800C4D
:10008000500C090C040C000C000C010C020C020CAE
:10009000010C000C050C240C000C100C010C040CC1
:1000A000240C020C020C050C240C060C000C010C98
:1000B000050C240C010C000C010C070C050C820C27
:1000C000030C080C000C020C090C040C010C000CB5
:1000D000020C0A0C000C000C000C070C050C030CA5
:1000E000020C400C000C000C070C050C830C020CDD
:1000F000400C000C000C0001080130016801840173
:10010000040C030C090C040C140C030C4D0C000C17
:10011000690C000C630C000C720C000C6F0C000CD2
:10012000630C000C680C000C690C000C700C000CCB
:100130001C0C030C500C000C490C000C430C000C64
:10014000310C000C380C000C200C000C550C000C71
:10015000530C000C420C000C200C000C430C000C47
:10016000440C000C430C000C0E0C030C560C000C41
:10017000310C000C2E0C000C310C000C460C000C49
:10018000530C000C0A0C030C430C000C660C000C06
:10019000670C000C310C000C04012E51600B0008A0
:1001A0003EE1050E2F6303D0040E2A6F36D0060EF3
:1001B0002F6301D035D0080E2F6309D02B0E226F8C
:1001C000040E236F010E286F296B2D9326D0090E84
:1001D0002F6301D06AD0000E2F6301D07ED0010EB4
:1001E0002F6301D09FD0030E2F6301D09BD00A0E46
:1001F0002F630BD02C0E226F040E236F3251222757
:10020000010E286F296B2D9308D00B0E2F6312005F
:1002100024EE2CF0325130C4DBFF010E276F1200A8
:10022000800E2E631200010E31630FD0480E226F34
:10023000000E236F22C4F6FF23C4F7FFF86A0800FC
:10024000F5CF28F4296B2D83E8D7020E316312D045
:10025000700E226F000E236F740EF66E000EF76E96
:10026000F86A0900F5CF28F409000900F5CF29F450
:100270002D83D3D7030E31631200F86AF76A304535
:10028000F60FF66E000EF7220900F5CF22F40800F3
:10029000F5CF23F422C4F6FF23C4F7FFF86A080061
:1002A000F5CF28F4296B2D83B8D7010E276F2FEED9
:1002B00071F00F0EDE6AE82EFDD724EE2CF0010E51
:1002C000DE6AE82EFDD730512B6F03E1050E2A6F51
:1002D0001200060E2A6F08DA1200366B376B2E51A9
:1002E0001F0B000803E12DB136830ED02E511F0BDA
:1002F000010801E109D02E511F0B020807E134D893
:10030000DF50040B01E03681010E276F010E2763D9
:100310001200360E226F040E236F020E286F296B17
:100320002D931200010E306309D02E511F0B0008CF
:1003300005E12D81030E2F632D916FD7000E3063E1
:1003400012002E511F0B0208FBE132510F0BF8E097
:100350000BD8030E2F6303D0840EDF6E5ED7000E22
:1003600032AF880EDF6E59D724EE00F032453235B9
:10037000E846E846D9261200000E6C6205D000510E
:100380003C0B340805E010D0040E6C62120015D04E
:10039000000E266F000E276F286B296BFDDE000E06
:1003A000276379D045D977D0020E2663AFD057D8CE
:1003B000C80E00BD880E006F1200040E2A6306D01E
:1003C00030516E6E050ED8B4030E2A6F010E2663EF
:1003D0009DD005D8C80E04BD880E046F12002851A8
:1003E000206F2951216F000804E307E12851080814
:1003F00004E2080E206F000E216F2051056F285F68
:100400002151295B0451FC0B2111046F24EE36F0BD
:10041000215102E1205122E02DA312D022C4F6FF87
:1004200023C4F7FFF86A0900F5CFDEFF09002007B3
:10043000FAE12107F8E2F6CF22F4F7CF23F4120015
:1004400022C4E1FF23C4E2FFE6CFDEFF2007FCE188
:100450002107FAE2E1CF22F4E2CF23F412000151A6
:10046000206F28270051030B216F292314EE36F04B
:1004700024C4D9FF25C4DAFF215102E120510AE04A
:10048000E6CFDEFF2007FCE12107FAE2D9CF24F412
:10049000DACF25F41200000E27630AD0080E016F90
:1004A0002E0E026F040E036F840E006F046F2CD0AB
:1004B0002EAF1DD02951355D04E307E12851345D8D
:1004C00004E234C428F435C429F489DF010E266F10
:1004D000080E016F2E0E026F040E036F800E006F68
:1004E000360E066F040E076FC80E046F0DD0020E95
:1004F000266F056BC80E046F080E016F360E026F73
:10050000040E036FC80E006F6D981200000E266F68
:10051000080E016F2E0E026F040E036F880E006F1F
:10052000000E046F12000401140E6F6E000E2A6F8D
:100530002D6B2B6BD9D8120004016DA60CD8010EBF
:100540002A6312006DBA1200686A696A6980698854
:10055000020E2A6F12006D6A696A6D86010E2A6F9B
:10056000120004016D6A696A000E2A6F120004010C
:10057000000E2A5D23E068A402D069B424D86DB2CD
:10058000120068A002D069B039D868A802D069B852
:1005900016D868AC02D069BC28D868AA02D069BA5B
:1005A00026D868A202D069B227D8030E2A5D06E3D6
:1005B00068A604D069A602D0DFDE689612006984BE
:1005C00068986D8212006D9269946894120004011B
:1005D0002DA11200F8DF6D84100EDA6ED96AD92EC3
:1005E000FED7DA2EFCD76D941200689C120070B012
:1005F0008DDF7090689A1200689212006A6A686AC9
:100600009F0E6B6E7B0E696E6E6A2FEE71F00F0E91
:10061000DE6AE82EFDD7160E706E68B6689668B66C
:10062000FDD76D9873DF2D912B6B030E2A6F12008F
:1006300004012E511F0B010809E12E51600B200807
:1006400005E1000E325D03E0010E32631200000E80
:100650002F6309D0460E226F040E236F2D93080ED0
:10066000286F296B3ED0010E2F6305D0460E246FF4
:10067000040E256F36D0020E2F6301D01200030E38
:100680002F6301D01200040E2F6301D01200200E40
:100690002F6305D03E0E246F040E256F22D0210E4D
:1006A0002F6314D0000E3E6FC20E3F6F010E406FDD
:1006B000416B426B436B080E446F3E0E226F040E7B
:1006C000236F2D93070E286F296B0BD0220E2F63FB
:1006D00003D030C445F405D0230E2F6301D012009F
:1006E0001200030E276F1200020EE96E14EE4EF098
:1006F000080E0CD8030EE96E14EE57F0400E1CD80D
:10070000030EE96E14EE98F0400E00D0E66E2FEE68
:1007100070F0E950D9261A0EDF12E944E846E8469F
:1007200004EE04F0E926020EE1CFEBFF030EE2CF68
:10073000EBFF400EEF6E1200E66E2FEE70F0E95008
:10074000D9261C0EDF12E944E846E84604EE00F024
:10075000E926020EE1CFEBFF030EE2CFEBFFE550FF
:10076000E92AE7CFEDFF880EEF6E1200006E04015C
:10077000060E2A5D000ED89009E1E944E846E846F5
:1007800004EE04F0E926000ED890EFBE1200020E2F
:10079000EBCFD9FF030EEBCFDAFFFF0EDB5000608B
:1007A000006EE92A0050ED6E04E0E6CFDEFFE82E91
:1007B000FCD7400EEF16EF7C880EEF120050D88069
:1007C0001200006E0401060E2A5D000ED89009E1A9
:1007D000E944E846E84604EE00F0E926000ED89029
:1007E000EFBE1200020EEBCFD9FF030EEBCFDAFF04
:1007F000EC500060006EFF0EDB50ED6E005004E028
:10080000DECFE6FFE82EFCD7400EEF16EF7C880E19
:10081000EF120050D880120081809390030E036E77
:10082000E80E03EC00F081909390030E036EE80E47
:1008300003EC00F081809390030E036EE80E03EC4E
:1008400000F071DE1FEC00F081909390010E036EBA
:10085000F40E03EC00F0818093906EDE88DE1FECD6
:1008600000F0100E1A6E030EE96E10EE1BF01A5017
:10087000A8DF1FEC00F01A6ED8A0EFD7817093901C
:10088000480E1B6E650E1C6E6C0E1D6E6C0E1E6E81
:100890006F0E1F6E200E206E570E216E6F0E226E91
:1008A000720E236E6C0E246E640E256E0D0E266E77
:1008B0000A0E276E286A40DE5ADE1FEC00F0030E97
:1008C000E96E10EE1BF00E0E51DF1FEC00F0D8A009
:1008D000F2D7C3D7FFFFFFFFFFFFFFFFFFFFFFFFC1
:1008E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF18
:08000000FFFFFFFFFFFFFFFF00
:020000040030CA
:0E00000020CF3F0F0085A1000FC00FE00F4082
:0200000400F00A
:10000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
:10004000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0
:10005000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB0
:10006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0
:10007000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF90
:10008000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80
:10009000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70
:1000A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60
:1000B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF50
:1000C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40
:1000D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30
:1000E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20
:1000F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF10
:00000001FF

f_lez
- 1st November 2009, 14:21
Pic 18f2550 USB-CDC 16Mhz

When burned to pic and built up on a board fit led to portb.0 it will flash twice and then init usb connection

LED should be on for one second and off one second, if not check your crystal is right and your programmer has not changed any of the fuse settings to a different pll/cpu div

This is for a 16mhz crystal to the pll (pll/1) and cpudiv=1(pll/2) which is 48mhz clocking




:020000040000FA
:1000000022EF00F0036A026EFF0E0226D8A003263C
:10001000D8A01FEF00F0030E016EE70E02D8F4D750
:10002000016AFD0F006EFF0E00D001D00026040013
:1000300000D000D0D8A00126D8A01200F7D7000128
:10004000040012000CEF04F0120C010C100C010C57
:10005000020C000C000C080CD80C040C0A0C000C50
:10006000000C000C010C020C030C010C7000700061
:10007000090C020C430C000C020C010C020C800C4D
:10008000500C090C040C000C000C010C020C020CAE
:10009000010C000C050C240C000C100C010C040CC1
:1000A000240C020C020C050C240C060C000C010C98
:1000B000050C240C010C000C010C070C050C820C27
:1000C000030C080C000C020C090C040C010C000CB5
:1000D000020C0A0C000C000C000C070C050C030CA5
:1000E000020C400C000C000C070C050C830C020CDD
:1000F000400C000C000C0001080130016801840173
:10010000040C030C090C040C140C030C4D0C000C17
:10011000690C000C630C000C720C000C6F0C000CD2
:10012000630C000C680C000C690C000C700C000CCB
:100130001C0C030C500C000C490C000C430C000C64
:10014000310C000C380C000C200C000C550C000C71
:10015000530C000C420C000C200C000C430C000C47
:10016000440C000C430C000C0E0C030C560C000C41
:10017000310C000C2E0C000C310C000C460C000C49
:10018000530C000C0A0C030C430C000C660C000C06
:10019000670C000C310C000C04012E51600B0008A0
:1001A0003EE1050E2F6303D0040E2A6F36D0060EF3
:1001B0002F6301D035D0080E2F6309D02B0E226F8C
:1001C000040E236F010E286F296B2D9326D0090E84
:1001D0002F6301D06AD0000E2F6301D07ED0010EB4
:1001E0002F6301D09FD0030E2F6301D09BD00A0E46
:1001F0002F630BD02C0E226F040E236F3251222757
:10020000010E286F296B2D9308D00B0E2F6312005F
:1002100024EE2CF0325130C4DBFF010E276F1200A8
:10022000800E2E631200010E31630FD0480E226F34
:10023000000E236F22C4F6FF23C4F7FFF86A0800FC
:10024000F5CF28F4296B2D83E8D7020E316312D045
:10025000700E226F000E236F740EF66E000EF76E96
:10026000F86A0900F5CF28F409000900F5CF29F450
:100270002D83D3D7030E31631200F86AF76A304535
:10028000F60FF66E000EF7220900F5CF22F40800F3
:10029000F5CF23F422C4F6FF23C4F7FFF86A080061
:1002A000F5CF28F4296B2D83B8D7010E276F2FEED9
:1002B00071F00F0EDE6AE82EFDD724EE2CF0010E51
:1002C000DE6AE82EFDD730512B6F03E1050E2A6F51
:1002D0001200060E2A6F08DA1200366B376B2E51A9
:1002E0001F0B000803E12DB136830ED02E511F0BDA
:1002F000010801E109D02E511F0B020807E134D893
:10030000DF50040B01E03681010E276F010E2763D9
:100310001200360E226F040E236F020E286F296B17
:100320002D931200010E306309D02E511F0B0008CF
:1003300005E12D81030E2F632D916FD7000E3063E1
:1003400012002E511F0B0208FBE132510F0BF8E097
:100350000BD8030E2F6303D0840EDF6E5ED7000E22
:1003600032AF880EDF6E59D724EE00F032453235B9
:10037000E846E846D9261200000E6C6205D000510E
:100380003C0B340805E010D0040E6C62120015D04E
:10039000000E266F000E276F286B296BFDDE000E06
:1003A000276379D045D977D0020E2663AFD057D8CE
:1003B000C80E00BD880E006F1200040E2A6306D01E
:1003C00030516E6E050ED8B4030E2A6F010E2663EF
:1003D0009DD005D8C80E04BD880E046F12002851A8
:1003E000206F2951216F000804E307E12851080814
:1003F00004E2080E206F000E216F2051056F285F68
:100400002151295B0451FC0B2111046F24EE36F0BD
:10041000215102E1205122E02DA312D022C4F6FF87
:1004200023C4F7FFF86A0900F5CFDEFF09002007B3
:10043000FAE12107F8E2F6CF22F4F7CF23F4120015
:1004400022C4E1FF23C4E2FFE6CFDEFF2007FCE188
:100450002107FAE2E1CF22F4E2CF23F412000151A6
:10046000206F28270051030B216F292314EE36F04B
:1004700024C4D9FF25C4DAFF215102E120510AE04A
:10048000E6CFDEFF2007FCE12107FAE2D9CF24F412
:10049000DACF25F41200000E27630AD0080E016F90
:1004A0002E0E026F040E036F840E006F046F2CD0AB
:1004B0002EAF1DD02951355D04E307E12851345D8D
:1004C00004E234C428F435C429F489DF010E266F10
:1004D000080E016F2E0E026F040E036F800E006F68
:1004E000360E066F040E076FC80E046F0DD0020E95
:1004F000266F056BC80E046F080E016F360E026F73
:10050000040E036FC80E006F6D981200000E266F68
:10051000080E016F2E0E026F040E036F880E006F1F
:10052000000E046F12000401140E6F6E000E2A6F8D
:100530002D6B2B6BD9D8120004016DA60CD8010EBF
:100540002A6312006DBA1200686A696A6980698854
:10055000020E2A6F12006D6A696A6D86010E2A6F9B
:10056000120004016D6A696A000E2A6F120004010C
:10057000000E2A5D23E068A402D069B424D86DB2CD
:10058000120068A002D069B039D868A802D069B852
:1005900016D868AC02D069BC28D868AA02D069BA5B
:1005A00026D868A202D069B227D8030E2A5D06E3D6
:1005B00068A604D069A602D0DFDE689612006984BE
:1005C00068986D8212006D9269946894120004011B
:1005D0002DA11200F8DF6D84100EDA6ED96AD92EC3
:1005E000FED7DA2EFCD76D941200689C120070B012
:1005F0008DDF7090689A1200689212006A6A686AC9
:100600009F0E6B6E7B0E696E6E6A2FEE71F00F0E91
:10061000DE6AE82EFDD7160E706E68B6689668B66C
:10062000FDD76D9873DF2D912B6B030E2A6F12008F
:1006300004012E511F0B010809E12E51600B200807
:1006400005E1000E325D03E0010E32631200000E80
:100650002F6309D0460E226F040E236F2D93080ED0
:10066000286F296B3ED0010E2F6305D0460E246FF4
:10067000040E256F36D0020E2F6301D01200030E38
:100680002F6301D01200040E2F6301D01200200E40
:100690002F6305D03E0E246F040E256F22D0210E4D
:1006A0002F6314D0000E3E6FC20E3F6F010E406FDD
:1006B000416B426B436B080E446F3E0E226F040E7B
:1006C000236F2D93070E286F296B0BD0220E2F63FB
:1006D00003D030C445F405D0230E2F6301D012009F
:1006E0001200030E276F1200020EE96E14EE4EF098
:1006F000080E0CD8030EE96E14EE57F0400E1CD80D
:10070000030EE96E14EE98F0400E00D0E66E2FEE68
:1007100070F0E950D9261A0EDF12E944E846E8469F
:1007200004EE04F0E926020EE1CFEBFF030EE2CF68
:10073000EBFF400EEF6E1200E66E2FEE70F0E95008
:10074000D9261C0EDF12E944E846E84604EE00F024
:10075000E926020EE1CFEBFF030EE2CFEBFFE550FF
:10076000E92AE7CFEDFF880EEF6E1200006E04015C
:10077000060E2A5D000ED89009E1E944E846E846F5
:1007800004EE04F0E926000ED890EFBE1200020E2F
:10079000EBCFD9FF030EEBCFDAFFFF0EDB5000608B
:1007A000006EE92A0050ED6E04E0E6CFDEFFE82E91
:1007B000FCD7400EEF16EF7C880EEF120050D88069
:1007C0001200006E0401060E2A5D000ED89009E1A9
:1007D000E944E846E84604EE00F0E926000ED89029
:1007E000EFBE1200020EEBCFD9FF030EEBCFDAFF04
:1007F000EC500060006EFF0EDB50ED6E005004E028
:10080000DECFE6FFE82EFCD7400EEF16EF7C880E19
:10081000EF120050D880120081809390030E036E77
:10082000E80E03EC00F081909390030E036EE80E47
:1008300003EC00F081809390030E036EE80E03EC4E
:1008400000F071DE1FEC00F081909390010E036EBA
:10085000F40E03EC00F0818093906EDE88DE1FECD6
:1008600000F0100E1A6E030EE96E10EE1BF01A5017
:10087000A8DF1FEC00F01A6ED8A0EFD7817093901C
:10088000480E1B6E650E1C6E6C0E1D6E6C0E1E6E81
:100890006F0E1F6E200E206E570E216E6F0E226E91
:1008A000720E236E6C0E246E640E256E0D0E266E77
:1008B0000A0E276E286A40DE5ADE1FEC00F0030E97
:1008C000E96E10EE1BF00E0E51DF1FEC00F0D8A009
:1008D000F2D7C3D7FFFFFFFFFFFFFFFFFFFFFFFFC1
:1008E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF18
:1008F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF08
:10090000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7
:107FC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC1
:107FD000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB1
:107FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA1
:107FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91
:020000040020DA
:08000000FFFFFFFFFFFFFFFF00
:020000040030CA
:0E00000023CF3F0F0085A1000FC00FE00F407F
:0200000400F00A
:10000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
:10004000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0
:10005000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB0
:10006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0
:10007000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF90
:10008000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80
:10009000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70
:1000A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60
:1000B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF50
:1000C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40
:1000D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30
:1000E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20
:1000F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF10
:00000001FF

f_lez
- 1st November 2009, 14:25
Pic 18f2550 USB-CDC 20Mhz

When burned to pic and built up on a board fit led to portb.0 it will flash twice and then init usb connection

LED should be on for one second and off one second, if not check your crystal is right and your programmer has not changed any of the fuse settings to a different pll/cpu div

This is for a 20mhz crystal to the pll (pll/1) and cpudiv=1(pll/2) which is 48mhz clocking



:020000040000FA
:1000000022EF00F0036A026EFF0E0226D8A003263C
:10001000D8A01FEF00F0030E016EE70E02D8F4D750
:10002000016AFD0F006EFF0E00D001D00026040013
:1000300000D000D0D8A00126D8A01200F7D7000128
:10004000040012000CEF04F0120C010C100C010C57
:10005000020C000C000C080CD80C040C0A0C000C50
:10006000000C000C010C020C030C010C7000700061
:10007000090C020C430C000C020C010C020C800C4D
:10008000500C090C040C000C000C010C020C020CAE
:10009000010C000C050C240C000C100C010C040CC1
:1000A000240C020C020C050C240C060C000C010C98
:1000B000050C240C010C000C010C070C050C820C27
:1000C000030C080C000C020C090C040C010C000CB5
:1000D000020C0A0C000C000C000C070C050C030CA5
:1000E000020C400C000C000C070C050C830C020CDD
:1000F000400C000C000C0001080130016801840173
:10010000040C030C090C040C140C030C4D0C000C17
:10011000690C000C630C000C720C000C6F0C000CD2
:10012000630C000C680C000C690C000C700C000CCB
:100130001C0C030C500C000C490C000C430C000C64
:10014000310C000C380C000C200C000C550C000C71
:10015000530C000C420C000C200C000C430C000C47
:10016000440C000C430C000C0E0C030C560C000C41
:10017000310C000C2E0C000C310C000C460C000C49
:10018000530C000C0A0C030C430C000C660C000C06
:10019000670C000C310C000C04012E51600B0008A0
:1001A0003EE1050E2F6303D0040E2A6F36D0060EF3
:1001B0002F6301D035D0080E2F6309D02B0E226F8C
:1001C000040E236F010E286F296B2D9326D0090E84
:1001D0002F6301D06AD0000E2F6301D07ED0010EB4
:1001E0002F6301D09FD0030E2F6301D09BD00A0E46
:1001F0002F630BD02C0E226F040E236F3251222757
:10020000010E286F296B2D9308D00B0E2F6312005F
:1002100024EE2CF0325130C4DBFF010E276F1200A8
:10022000800E2E631200010E31630FD0480E226F34
:10023000000E236F22C4F6FF23C4F7FFF86A0800FC
:10024000F5CF28F4296B2D83E8D7020E316312D045
:10025000700E226F000E236F740EF66E000EF76E96
:10026000F86A0900F5CF28F409000900F5CF29F450
:100270002D83D3D7030E31631200F86AF76A304535
:10028000F60FF66E000EF7220900F5CF22F40800F3
:10029000F5CF23F422C4F6FF23C4F7FFF86A080061
:1002A000F5CF28F4296B2D83B8D7010E276F2FEED9
:1002B00071F00F0EDE6AE82EFDD724EE2CF0010E51
:1002C000DE6AE82EFDD730512B6F03E1050E2A6F51
:1002D0001200060E2A6F08DA1200366B376B2E51A9
:1002E0001F0B000803E12DB136830ED02E511F0BDA
:1002F000010801E109D02E511F0B020807E134D893
:10030000DF50040B01E03681010E276F010E2763D9
:100310001200360E226F040E236F020E286F296B17
:100320002D931200010E306309D02E511F0B0008CF
:1003300005E12D81030E2F632D916FD7000E3063E1
:1003400012002E511F0B0208FBE132510F0BF8E097
:100350000BD8030E2F6303D0840EDF6E5ED7000E22
:1003600032AF880EDF6E59D724EE00F032453235B9
:10037000E846E846D9261200000E6C6205D000510E
:100380003C0B340805E010D0040E6C62120015D04E
:10039000000E266F000E276F286B296BFDDE000E06
:1003A000276379D045D977D0020E2663AFD057D8CE
:1003B000C80E00BD880E006F1200040E2A6306D01E
:1003C00030516E6E050ED8B4030E2A6F010E2663EF
:1003D0009DD005D8C80E04BD880E046F12002851A8
:1003E000206F2951216F000804E307E12851080814
:1003F00004E2080E206F000E216F2051056F285F68
:100400002151295B0451FC0B2111046F24EE36F0BD
:10041000215102E1205122E02DA312D022C4F6FF87
:1004200023C4F7FFF86A0900F5CFDEFF09002007B3
:10043000FAE12107F8E2F6CF22F4F7CF23F4120015
:1004400022C4E1FF23C4E2FFE6CFDEFF2007FCE188
:100450002107FAE2E1CF22F4E2CF23F412000151A6
:10046000206F28270051030B216F292314EE36F04B
:1004700024C4D9FF25C4DAFF215102E120510AE04A
:10048000E6CFDEFF2007FCE12107FAE2D9CF24F412
:10049000DACF25F41200000E27630AD0080E016F90
:1004A0002E0E026F040E036F840E006F046F2CD0AB
:1004B0002EAF1DD02951355D04E307E12851345D8D
:1004C00004E234C428F435C429F489DF010E266F10
:1004D000080E016F2E0E026F040E036F800E006F68
:1004E000360E066F040E076FC80E046F0DD0020E95
:1004F000266F056BC80E046F080E016F360E026F73
:10050000040E036FC80E006F6D981200000E266F68
:10051000080E016F2E0E026F040E036F880E006F1F
:10052000000E046F12000401140E6F6E000E2A6F8D
:100530002D6B2B6BD9D8120004016DA60CD8010EBF
:100540002A6312006DBA1200686A696A6980698854
:10055000020E2A6F12006D6A696A6D86010E2A6F9B
:10056000120004016D6A696A000E2A6F120004010C
:10057000000E2A5D23E068A402D069B424D86DB2CD
:10058000120068A002D069B039D868A802D069B852
:1005900016D868AC02D069BC28D868AA02D069BA5B
:1005A00026D868A202D069B227D8030E2A5D06E3D6
:1005B00068A604D069A602D0DFDE689612006984BE
:1005C00068986D8212006D9269946894120004011B
:1005D0002DA11200F8DF6D84100EDA6ED96AD92EC3
:1005E000FED7DA2EFCD76D941200689C120070B012
:1005F0008DDF7090689A1200689212006A6A686AC9
:100600009F0E6B6E7B0E696E6E6A2FEE71F00F0E91
:10061000DE6AE82EFDD7160E706E68B6689668B66C
:10062000FDD76D9873DF2D912B6B030E2A6F12008F
:1006300004012E511F0B010809E12E51600B200807
:1006400005E1000E325D03E0010E32631200000E80
:100650002F6309D0460E226F040E236F2D93080ED0
:10066000286F296B3ED0010E2F6305D0460E246FF4
:10067000040E256F36D0020E2F6301D01200030E38
:100680002F6301D01200040E2F6301D01200200E40
:100690002F6305D03E0E246F040E256F22D0210E4D
:1006A0002F6314D0000E3E6FC20E3F6F010E406FDD
:1006B000416B426B436B080E446F3E0E226F040E7B
:1006C000236F2D93070E286F296B0BD0220E2F63FB
:1006D00003D030C445F405D0230E2F6301D012009F
:1006E0001200030E276F1200020EE96E14EE4EF098
:1006F000080E0CD8030EE96E14EE57F0400E1CD80D
:10070000030EE96E14EE98F0400E00D0E66E2FEE68
:1007100070F0E950D9261A0EDF12E944E846E8469F
:1007200004EE04F0E926020EE1CFEBFF030EE2CF68
:10073000EBFF400EEF6E1200E66E2FEE70F0E95008
:10074000D9261C0EDF12E944E846E84604EE00F024
:10075000E926020EE1CFEBFF030EE2CFEBFFE550FF
:10076000E92AE7CFEDFF880EEF6E1200006E04015C
:10077000060E2A5D000ED89009E1E944E846E846F5
:1007800004EE04F0E926000ED890EFBE1200020E2F
:10079000EBCFD9FF030EEBCFDAFFFF0EDB5000608B
:1007A000006EE92A0050ED6E04E0E6CFDEFFE82E91
:1007B000FCD7400EEF16EF7C880EEF120050D88069
:1007C0001200006E0401060E2A5D000ED89009E1A9
:1007D000E944E846E84604EE00F0E926000ED89029
:1007E000EFBE1200020EEBCFD9FF030EEBCFDAFF04
:1007F000EC500060006EFF0EDB50ED6E005004E028
:10080000DECFE6FFE82EFCD7400EEF16EF7C880E19
:10081000EF120050D880120081809390030E036E77
:10082000E80E03EC00F081909390030E036EE80E47
:1008300003EC00F081809390030E036EE80E03EC4E
:1008400000F071DE1FEC00F081909390010E036EBA
:10085000F40E03EC00F0818093906EDE88DE1FECD6
:1008600000F0100E1A6E030EE96E10EE1BF01A5017
:10087000A8DF1FEC00F01A6ED8A0EFD7817093901C
:10088000480E1B6E650E1C6E6C0E1D6E6C0E1E6E81
:100890006F0E1F6E200E206E570E216E6F0E226E91
:1008A000720E236E6C0E246E640E256E0D0E266E77
:1008B0000A0E276E286A40DE5ADE1FEC00F0030E97
:1008C000E96E10EE1BF00E0E51DF1FEC00F0D8A009
:1008D000F2D7C3D7FFFFFFFFFFFFFFFFFFFFFFFFC1
:1008E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF18
:107FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA1
:107FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91
:020000040020DA
:08000000FFFFFFFFFFFFFFFF00
:020000040030CA
:0E00000024CF3F0F0085A1000FC00FE00F407E
:0200000400F00A
:10000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
:10004000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0
:10005000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB0
:10006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0
:10007000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF90
:10008000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80
:10009000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70
:1000A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60
:1000B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF50
:1000C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40
:1000D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30
:1000E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20
:1000F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF10
:00000001FF