View previous topic :: View next topic |
Author |
Message |
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
18F25K50 ex_usb_hid example |
Posted: Sat Jun 08, 2013 5:54 am |
|
|
It falls over in pic18_usb.c on
Code: | #byte UFRMH = getenv("SFR:UFRMH") |
with Bad SFR Name, but as far as I can see, it is defined. I don't really understand getenv.. where does it get the cpu specific definitions from?
Last edited by oxo on Fri Jun 14, 2013 12:02 am; edited 1 time in total |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Jun 08, 2013 7:45 am |
|
|
Always post your compiler version!
The version number looks like 4.xxx and can be found in several places:
1) The easiest way to find this is when in Windows you open the menu: Start / PIC-C/Compiler Version
2) In the CCS IDE, top right is a '?' symbol, click this, then select 'About'.
3) In the top of the compiled list file (*.lst), but this requires your program to compile.
CCS maintains many of the chip specific settings in a database and with the many new chips being released they sometimes forget a feature.
When you have a compiler version with IDE (that is, PCWH or PCWHD) then there is in the PICC program files directory a program called chipedit.exe.
Start this program, select your chip model and then from the top menu select 'registers'.
My version 4.141 shows the UFRMH register at the correct address F69. That's why I suspect you have an older version?
I didn't try to compile the example program, but as the example program was created for one of the CCS Demo Boards you will have to make some changes in ex_usb_common.h to fit your hardware configuration. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Jun 08, 2013 8:36 am |
|
|
As another comment, remember that CCS often reports errors in a different place to where they are actually happening....
How are you actually selecting this processor?.
You have to add the section for it, to the ex_usb_common.h, as:
Code: |
#define USB_HW_MCHP_18F25K50 //rem out the other defines
#define __EX_USB_COMMON_H__ //then after this line
//new section
#if defined(USB_HW_MCHP_18F25K50)
#include <18F25K50.h>
#FUSES //fuses here to suit your configuration
#use delay(clock=48MHz)
//leds ordered from bottom to top
#DEFINE LED1 PIN_A5 //green
#define LED2 PIN_B4 //yellow
#define LED3 PIN_B5 //red
#define BUTTON_PRESSED() !input(PIN_A4)
//see section below labeled USB_CABLE_IS_ATTACHED
#define PIN_USB_SENSE PIN_B2
#define HW_ADC_CONFIG ADC_CLOCK_DIV_64
#define HW_ADC_CHANNEL 0
#define HW_ADC_PORTS sAN0
#endif
|
Then in pic18_usb.c:
Code: |
#elif ((getenv("DEVICE")=="PIC18F13K50") || (getenv("DEVICE")=="PIC18F14K50") || \
(getenv("DEVICE")=="PIC18LF13K50") || (getenv("DEVICE")=="PIC18LF14K50")) || \
(getenv("DEVICE")=="PIC18F25K50")
#define __USB_K50__
|
Just one extra line here. Search for the USB_K50, and it is the line above, and three characters at the end of the previous line.
What is happening, is that the definitions of the USB 'type' to select are not right somewhere, and it is complaining when it gets to your line.
With the changes above, the example (and the other usb examples), all compile OK with 4.141, and this processor.
Best Wishes |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Sat Jun 08, 2013 10:00 am |
|
|
I have the latest version.. Only updated 4 days ago, and I also have v5 ide
I'm not at my work pic right now, but I'll try those things in the morning.
Thank you. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Jun 08, 2013 10:06 am |
|
|
Go back to 4.141, do the changes I outline, and use a working compiler, rather than a beta......
Seriously, I'm going to wait at least a couple of months before I try V5, or until I find a processor not supported by V4. V5 is beta. As a 'beta tester' which is what you are, report the problems to CCS. However given the number of problems with bits of V5 (work out how quickly we are on the fifth release of this), don't expect a quick fix....
Learn a 'mantra' about CCS - They use their customers as beta testers, and don't make this always obvious. So while they were showing v5 as beta on their site, they still were downloading it to people when a standard 'upgrade' was asked for. Always use the older version when 'new' things are launched, unless you must have a feature in the new version, and are happy to be beta testing.
Best Wishes |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Mon Jun 10, 2013 1:05 am |
|
|
Still stuck, because I don't have a copy of 4.141. I've asked CCS for it. The last V4 I have is 4.132, and that won't compile.
I also have a tech support query in with CCS since Friday.
I guess all I have to do is wait now. |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Tue Jun 11, 2013 3:10 am |
|
|
Thanks.
It compiles now.
While I'm here, has anybody seen this example working on the 25K50? |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Wed Jun 12, 2013 3:10 am |
|
|
It compiles and runs now, but won't enumerate. The odd thing is that if I leave the ICD-U64 connected it seems to reset and retry the enumeration every 3 seconds or so. Doesn't do this if I program then disconnect the pod.
The PC does that USB bong on connection, but then says USB device not recognised.
I assume from the fact that we had to make changes to the code that this example has never been run on this chip.
Code: | ex_usb_common.h
#if defined(USB_HW_GENERIC_18F25K50)
#include <18F25K50.h>
#fuses NOWDT
#use delay(crystal=12Mhz, clock=48Mhz, USB_FULL)
//leds ordered from bottom to top
#DEFINE LED1 PIN_A5 //green
#define LED2 PIN_B4 //yellow
#define LED3 PIN_B5 //red
#define BUTTON_PRESSED() !input(PIN_A4)
//see section below labeled USB_CABLE_IS_ATTACHED
// #define PIN_USB_SENSE PIN_B2
// #define HW_ADC_CONFIG ADC_CLOCK_INTERNAL
// #define HW_ADC_CHANNEL 0
// #define HW_ADC_PORTS sAN0
#endif
|
Code: | pic18_usb.c
#IFNDEF __PIC18_USB_C__
#DEFINE __PIC18_USB_C__
#INCLUDE <usb.h>
#bit USBIE=getenv("BIT:USBIE")
//if you are worried that the PIC is not receiving packets because a bug in the
//DATA0/DATA1 synch code, you can set this to TRUE to ignore the DTS on
//receiving.
#ifndef USB_IGNORE_RX_DTS
#define USB_IGNORE_RX_DTS FALSE
#endif
#ifndef USB_IGNORE_TX_DTS
#define USB_IGNORE_TX_DTS FALSE
#endif
#if ((getenv("DEVICE")=="PIC18F87J50") || (getenv("DEVICE")=="PIC18F86J55") || \
(getenv("DEVICE")=="PIC18F86J50") || (getenv("DEVICE")=="PIC18F85J50") || \
(getenv("DEVICE")=="PIC18F67J50") || (getenv("DEVICE")=="PIC18F66J55") || \
(getenv("DEVICE")=="PIC18F66J50") || (getenv("DEVICE")=="PIC18F65J50"))
#define __USB_87J50__
#define USB_TOTAL_RAM_SPACE ((unsigned int16)getenv("RAM")-0x400)
#define USB_RAM_START 0x400
#define USB_NUM_UEP 16
#define USB_LAST_ALLOWED_ENDPOINT 16
#elif ((getenv("DEVICE")=="PIC18F45K50") || \
(getenv("DEVICE")=="PIC18F25K50") || \
(getenv("DEVICE")=="PIC18F24K50"))
#define __USB_45K50__
#define USB_TOTAL_RAM_SPACE 1024
#define USB_RAM_START 0x400
#define USB_NUM_UEP 16
#define USB_LAST_ALLOWED_ENDPOINT 16
#define USB_PIC_NO_USB_GPIO //D+ and D- are not shared with any GPIO
#elif ((getenv("DEVICE")=="PIC18F24J50") || (getenv("DEVICE")=="PIC18F25J50") || \
(getenv("DEVICE")=="PIC18F26J50") || (getenv("DEVICE")=="PIC18F44J50") || \
(getenv("DEVICE")=="PIC18F45J50") || (getenv("DEVICE")=="PIC18F46J50"))
#define __USB_46J50__
#define USB_TOTAL_RAM_SPACE ((unsigned int16)getenv("RAM")-0x400)
#define USB_RAM_START 0x400
#define USB_NUM_UEP 16
#define USB_LAST_ALLOWED_ENDPOINT 16
#elif ((getenv("DEVICE")=="PIC18F2450") || (getenv("DEVICE")=="PIC18F4450"))
#define __USB_4450__
#define USB_TOTAL_RAM_SPACE ((unsigned int16)0x100)
#define USB_RAM_START 0x400
#define USB_NUM_UEP 16
#define USB_LAST_ALLOWED_ENDPOINT 3
#elif ((getenv("DEVICE")=="PIC18F13K50") || (getenv("DEVICE")=="PIC18F14K50") || \
(getenv("DEVICE")=="PIC18LF13K50") || (getenv("DEVICE")=="PIC18LF14K50")) || \
(getenv("DEVICE")=="PIC18F25K50")
#define __USB_K50__ //backwards compatability
#define __USB_14K50__
#define USB_TOTAL_RAM_SPACE ((unsigned int16)0x100)
#define USB_RAM_START 0x200
#define USB_NUM_UEP 8
//technically this device supports 8 endpoints, but for RAM reasons you should
//attempt to only use the first 3 endpoints.
#define USB_LAST_ALLOWED_ENDPOINT 3
#elif ((getenv("DEVICE")=="PIC18F2455") || (getenv("DEVICE")=="PIC18F2550") || \
(getenv("DEVICE")=="PIC18F4455") || (getenv("DEVICE")=="PIC18F4550") || \
(getenv("DEVICE")=="PIC18F2458") || (getenv("DEVICE")=="PIC18F2553") || \
(getenv("DEVICE")=="PIC18F4458") || (getenv("DEVICE")=="PIC18F4553") \
)
#define __USB_4550__
#define USB_TOTAL_RAM_SPACE ((unsigned int16)0x400)
#define USB_RAM_START 0x400
#define USB_NUM_UEP 16
#define USB_LAST_ALLOWED_ENDPOINT 16
#elif ((getenv("DEVICE")=="PIC18F26J53") || (getenv("DEVICE")=="PIC18F27J53") || \
(getenv("DEVICE")=="PIC18F46J53") || (getenv("DEVICE")=="PIC18F47J53") \
)
#define __USB_18FJ53__
#define USB_TOTAL_RAM_SPACE (0xE00) //0x000:0xDFF. save 0x00:0xFF for compiler use
#define USB_BDT_START 0xD00
#define USB_NUM_UEP 16
#define USB_LAST_ALLOWED_ENDPOINT 16
#else
#error Unknown PIC device, USB not supported in this library.
#endif
|
|
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Thu Jun 13, 2013 12:52 pm |
|
|
This is now working, thanks to Darren @ CCS.
Quote: | The compiler doesn't know that for the PLL to work you need to use the high power EC or HS mode. So you can't use the fancy #use delay(), you will manually need to set the fuses:
#fuses NOCPUDIV, PLLEN, PLL4X, HSH, PRIMARY, NOIESO, NOFCMEN //12mhz crystal, 48mhz clock for pic and usb
#use delay(clock=48MHz)
I am using HSH because my board has a crystal. If your board doesn't have a crystal (it has an oscillator) than replace HSH with ECH. |
|
|
|
dsevgor
Joined: 30 Mar 2013 Posts: 11
|
|
Posted: Thu Jul 04, 2013 4:09 am |
|
|
I'm having the same problem and I didn't want to open a new thread.
My compiler version is 5.001
This can't be that hard to compile the ex_usb_bootloader.c but I failed.
I tried to open and compile ex_usb_bootloader directly from the examples. When I do that I get the "I/O error 103" so i get a copy of ex_usb_bootloader.c and ex_usb_bootloader.h and renamed in a different folder. This time I didn't get 103 error, at least.
I commented out "define USB_HW_CCS_PIC18F4550" and defined new for 18f2455 and also add if defined statement to the .h file with the same settings from 18f4550
Code: | #if defined(USB_HW_GENERIC_18F2455)
#include <18F2455.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
//leds ordered from bottom to top
#DEFINE LED1 PIN_A5 //green
#define LED2 PIN_B4 //yellow
#define LED3 PIN_B5 //red
#define BUTTON_PRESSED() !input(PIN_A4)
//see section below labeled USB_CABLE_IS_ATTACHED
#define PIN_USB_SENSE PIN_B2
#define HW_ADC_CONFIG ADC_CLOCK_INTERNAL
#define HW_ADC_CHANNEL 0
#define HW_ADC_PORTS AN0
#endif |
I also checked pic18_usb.c to see if
(getenv("DEVICE")=="PIC18F2455")
is defined. and yes it is defined under __USB_4550__
I simply tried to explain what i had tried. it may be a ccs v5 problem but doubt it. So the problem is probably me
If someone can help me I really appreciate. |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Thu Jul 04, 2013 4:56 am |
|
|
You say it compiles now? So what error do you have? |
|
|
dsevgor
Joined: 30 Mar 2013 Posts: 11
|
|
Posted: Thu Jul 04, 2013 5:19 am |
|
|
i get 100 errors starting with bad sfr name and lot of other things like undefined identifiers etc. |
|
|
dsevgor
Joined: 30 Mar 2013 Posts: 11
|
|
Posted: Thu Jul 04, 2013 7:16 am |
|
|
I was out of the office sorry for the insufficient reply.
I get 100 errors starting with error 28 line 118 (30,31) expecting an identifier Bad SFR name in pic18_usb.c and lot of expecting a declaration etc.
error 57 expecting a structure/union in usb.c (line 745 (28,29))
I'm sure I miss out something, but couldn't figure it out. |
|
|
dsevgor
Joined: 30 Mar 2013 Posts: 11
|
|
Posted: Thu Jul 04, 2013 7:18 am |
|
|
and again lots of expenting structure/union and a numeric expression must appear here errors. in usb/c |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Fri Jul 05, 2013 4:02 am |
|
|
do you have
#include <18f2455.h>
as the first thing in your code? |
|
|
|