Nuts n Volts HID demo Rebuilt

Author
spotty
Super Member
  • Total Posts : 280
  • Reward points : 0
  • Joined: 2008/04/03 11:15:31
  • Location: 0
  • Status: offline
2008/11/15 08:23:55 (permalink)
0

Nuts n Volts HID demo Rebuilt

Some while ago, in Nuts 'n Volts magazine, Alexander Enzmann published GPL'ed code to provide
USB HID interface. I've done a few typecast fixes to the code and rebuilt it, link edited to load
at 0x0800 so it's compatible with Microchip's USB booloader scheme. Here's a zipped file of the
complete directory which builds for me usng SDCC's latest release, 2.8.0
If you have the PIC's UART connected you can get debug information via the serial port, I found
it very useful in understanding how the USB setup progresses but beware, too many printf's will
cause timeouts on the USB interface; I added bitmasks to the debug switches so the volume
can be adjusted.
I was able to drop in the HID Joystick descriptors from USB org's site and see a USB joystick
show up; libhid and it's examples in both C and Python were a great help. This is work in progress
and is supplied 'as is', I hope it's helpful. Change the file extension to .tar.gz and then unzip.
#1

6 Replies Related Threads

    vaclavpe
    Starting Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2007/07/23 13:28:30
    • Location: 0
    • Status: offline
    RE: Nuts n Volts HID demo Rebuilt 2008/11/28 13:00:43 (permalink)
    0
    Hi,

    unfortunately, I can't send you personal message as it does not work on my Linux's Firefox :-(

    I have just question - is it enough to change LKR when I do not want to use bootloader ?

    I tried to use Alexander's USB stack but I never had any success :-( And I do not know, why. But had no problem with original Microchip's stack compiled with MCC-18

    I want to test it on PIC18F2455 and 20MHz XTAL - is it the configuration as on your system ?

    Thank you in advance

    #2
    spotty
    Super Member
    • Total Posts : 280
    • Reward points : 0
    • Joined: 2008/04/03 11:15:31
    • Location: 0
    • Status: offline
    RE: Nuts n Volts HID demo Rebuilt 2008/11/28 13:50:48 (permalink)
    0
    That's OK, my Linux Opera isn't receiving emails right now anyway !
    ( and opera can't upload attachments but firefox can .. )
    The linker file should be the only change necessary But: I took the config setting out of the source file since
    I wanted the bootloader to control configuration settings. There also were some errors in my debug printf switches
    that caused problems with certain switch settings.

    Here, attached, is the zipped directory with:
    Config settings in the main source file, g25.c, they should be correct for 20MHz but please check !
    Debug printf's #define switches cleaned up.
    Linker file should be good for origin at 0x0000, with the 0x0800 linker for comparison.

    I'm in the process of tossing 64bit and re installing with 32 bit OS's so I haven't been able to do an SDCC build on the attached, as soon as I can I'll verify it build ok and if there's a problem I'll re-post .. honestly.

    Edit Add: I've noticed various errors in USB Comp according to how much 'printf' activity is going on, turn off all debug for final tests.

    Rename file extension to .zip and unzip:
    post edited by spotty - 2008/11/28 14:04:48
    #3
    vaclavpe
    Starting Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2007/07/23 13:28:30
    • Location: 0
    • Status: offline
    RE: Nuts n Volts HID demo Rebuilt 2008/11/28 15:12:18 (permalink)
    0
    Thank you for your quick answer!

    I tried your G25 code but no success again. I use sdcc 2.8.4 from Oct 20, 2008 and gputils 0.13.4

    In LKR I shortened the code size to 0x5fff ( for 18f2455)

    In makefile I changed followinmg:
    - SDCC dir to /opt/sdcc
    - added CRTZ into HEX build - $(HEXF): $(CRTZ).o $(OBJS) $(LKRS)
    - removed --optimize-goto as it seems not yet supported
    - --ivt-loc=0x0800 - as vectors are from 0x0000
    - I generated pic18f2455.lib following way as I did not have it in nightly build:
    sdcc -mpic16 -p18f2455 --std-c99 -Wa,-q -I /opt/sdcc/share/sdcc/include/pic16/ --fommit-frame-pointer --obanksel=9 --denable-peeps --optimize-cmp --optimize-df --i-code-in-asm -o pic18f2455.o -c /opt/sdcc/share/sdcc/lib/src/pic16/libdev/pic18f2455.c
    gplib -c pic18f2455.lib pic18f2455.o

    The compilation went following way:
    bobika@supermuf:~/programovani/USB-spotty/g25> make
    /opt/sdcc/bin/sdcc -I. -I/opt/sdcc/share/sdcc/include/pic16 --model-small --optimize-cmp --optimize-df --opt-code-size --obanksel=9 --fommit-frame-pointer --use-crt=crt0iz-rloc.o -mpic16 -pp18f2455 -DFOS4=48000000 -c crt0iz-rloc.c -o crt0iz-rloc.o
    crt0iz-rloc.c:127: warning 187: ISO C90 does not support flexible array members
    for file in g25.c usb.c; do DIR=`dirname $file`; echo -n $DIR/ >> .depend; /opt/sdcc/bin/sdcc -I. -I/opt/sdcc/share/sdcc/include/pic16 --model-small --optimize-cmp --optimize-df --opt-code-size --obanksel=9 --fommit-frame-pointer --use-crt=crt0iz-rloc.o -mpic16 -pp18f2455 -DFOS4=48000000 -M $file >> .depend; done
    /opt/sdcc/bin/sdcc -I. -I/opt/sdcc/share/sdcc/include/pic16 --model-small --optimize-cmp --optimize-df --opt-code-size --obanksel=9 --fommit-frame-pointer --use-crt=crt0iz-rloc.o -mpic16 -pp18f2455 -DFOS4=48000000 -c g25.c -o g25.o
    /opt/sdcc/bin/sdcc -I. -I/opt/sdcc/share/sdcc/include/pic16 --model-small --optimize-cmp --optimize-df --opt-code-size --obanksel=9 --fommit-frame-pointer --use-crt=crt0iz-rloc.o -mpic16 -pp18f2455 -DFOS4=48000000 -c usb.c -o usb.o
    usb.c:666: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
    /opt/sdcc/bin/sdcc -I. -I/opt/sdcc/share/sdcc/include/pic16 --model-small --optimize-cmp --optimize-df --opt-code-size --obanksel=9 --fommit-frame-pointer --use-crt=crt0iz-rloc.o -mpic16 -pp18f2455 -DFOS4=48000000 -L /opt/sdcc/share/sdcc/lib/pic16 -Wl,"-m -w -s 18f2455-g25.lkr" -o g25 \
    g25.o usb.o libsdcc.lib libc18f.lib libio18f2455.lib pic18f2455.lib


    But PIC is completely dead. I even tried to add LED in the beginning of main() but it is not lighting I must say that MCHPUSB compiled with MCC18 works. So there should be no problem in HW.
    TRISAbits.TRISA3 = 0;
    LATAbits.LATA3 = 1;

    Is there something wrong with crt rloc ? I really do not know.

    I wil really appreciate your help.
    #4
    spotty
    Super Member
    • Total Posts : 280
    • Reward points : 0
    • Joined: 2008/04/03 11:15:31
    • Location: 0
    • Status: offline
    RE: Nuts n Volts HID demo Rebuilt 2008/11/28 15:25:51 (permalink)
    0
    At least you got to meet Evelyn ..
    I don't think the crt source files are changed from SDCC lib, just copied and recompiled so as to make the object file available
    in he local directory. I know my gputils is a little bit later because I just yummed it, so I to am using sdcc 2.8.0 and gputils 13.6
    It will take a little time but I'll spin up my Windows setup and try flashing the code that built here. I do remember the EEROM test
    at the end cause me problems, the data patterns go themselves executed as a sleep command, so that should be commented
    out. I'll flash a PIC as soon as I can .

    Edit Sorry about the Makefile, here's Xander's original that I thought I'd packed in ..
    post edited by spotty - 2008/11/28 15:30:07
    #5
    vaclavpe
    Starting Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2007/07/23 13:28:30
    • Location: 0
    • Status: offline
    RE: Nuts n Volts HID demo Rebuilt 2008/11/28 15:52:33 (permalink)
    0
    Hello Spotty,

    now I feel like stupid - as I normally do not use MCLR as a RESET but a normal pin. I played with the board and suddenly LED flashed... And in DMESG I found the device was detected !

    So I changed CONFIG3H - and problem was solved! I am soooooooo stupid :-)

    Sorry for the interruption of your reinstallation.
    Vaclav
    #6
    spotty
    Super Member
    • Total Posts : 280
    • Reward points : 0
    • Joined: 2008/04/03 11:15:31
    • Location: 0
    • Status: offline
    RE: Nuts n Volts HID demo Rebuilt 2008/11/28 17:26:49 (permalink)
    0
    Not at all, I'm glad it worked out for you. I think Xander's code is a great help for tracking through the
    USB calls, together with libhid it's helped me a lot. Best !
    #7
    Jump to:
    © 2014 APG vNext Commercial Version 4.5