 |
 |
| View previous topic :: View next topic |
| Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Aug 09, 2014 5:35 pm |
|
|
The code I used is from my previous post, here:
http://www.ccsinfo.com/forum/viewtopic.php?t=52722&start=8
The Teraterm setup instructions and link to the download for it is here:
http://www.ccsinfo.com/forum/viewtopic.php?t=39388&start=18
TeraTerm is used to send the '1' and '0' characters to the COM port.
Remember to look in Windows Device Manager to see what COM port
has been assigned to the USB board. You have to select that same
COM port (ie., COM4 or COM6 or whatever it is) in TeraTerm.
I'm using the older non-Rohs version of the PicDem2-Plus. The schematic
is in the back of this PDF:
http://ww1.microchip.com/downloads/en/DeviceDoc/PICDEM%202Plus%20Old%20Version%2051275b.pdf
On the Vusb pin of the 18F4550, I have a 4.7uF Tantalum capacitor.
I know Ttelmah says that's wrong, the value is too high, and I basically
agree, but I also know it works on my board and I didn't have a 470 nF
capacitor so I left it in there.
As I said in my post that I linked to above, the PicDem2-Plus has a 4.7K
pullup on pin C4 that had to be removed so it wouldn't interfere with the
USB pins.
I have a USB connector mounted on the board. I connected the ground
to the board's ground, and the D+ and D- pins to the 18F4550. I carefully
verified the pinout of the USB connector to make sure I had D+ and D-
going to the correct pins.
Here's a good schematic:
http://320volt.com/en/usb-uygulamalari-ccs-pic18f4550-pic18f2550/
The 1K on the MCLR is too low. Microchip wants it to be 10K for the ICD3
and CCS wants it to be 47K for their ICD-U64. I don't use the 1 Meg
resistor across the crystal. I've never found it necessary with the PICs
or crystals (ECS brand) that I use.
I also have the USB connection sense circuit installed. It consists of two
100K resistors. It was described in a ASCII Art schematic in an older
version of the CCS compiler example files. I can't find an example
right now. I'll post that later. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19993
|
|
Posted: Sun Aug 10, 2014 1:10 am |
|
|
As a comment PCM_programmer, I've kept on using the 'old' way of working with CCS. I found very early on that the automatic updating, and version switching, was a classic 'not working properly' bit of CCS code (why can't they concentrate on the compiler, not the frills?). The version switching, doesn't seem to always correctly change the include files used properly, and if the devices.dat is from a much older compiler version, it doesn't get handled correctly (I think this is what caused your problem).
I delete the automatic update utility (ccsload), when I install a new version, and just install each new version separately as I always used to do. This way it never tells me about 'new versions' (I can just check every few weeks, or if I see a comment here about something now working). It is far easier/safer than letting CCS stick their 'nose' into the update side of things!....
Though the reliability of the code has improved markedly in the last few years, I'm still a believer in not trusting any new release, and being 'sure' I know which release of everything, I'm actually using.
On the 4.7uF, the 'big' problem, is people fitting things like 4.7uF aluminium electrolytic capacitors thinking 'bigger is better' here, which then have poor HF performance. The better performance of tantalum means this is not a problem. The other problem is the same one as most regulators, that if the main supply rail drops faster than the USB rail, the regulator gets reverse biased. With something really large like 100uF, I'd get 'worried' by that, but at 4.7uF I'd be quite happy.  |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 10, 2014 1:28 pm |
|
|
I don't have a ccsload file with the command line compiler.
In c:\Program Files\PICC, the closest thing I have is ccscon.exe.
Deleting that file did not get rid of the multi-versioning system.
I'm going to make a batch file that deletes the DLL directory, Devices,
Drivers, and all the files in c:\Program Files\PICC.
CCS also has ccsc.ini and pcw.ini in this directory (on XP):
c:\Documents and Settings\<user name>\Application Data\PICC
I'm going to delete those too.
Edit:
This is the batch file I made. It seems to work. I get a clean install
of the desired version, without any old versions left in the PICC directory.
This was only tested on Windows XP, and wouldn't work with other
versions of Windows because they don't have deltree. But a work-around
could be done with del and rd. This batch file is only for removal of
the command line versions of the compiler. Also, it doesn't do anything
to the registry settings. It leaves them unchanged. MPLAB has to be
closed when running this batch file, or you will get an "access denied"
on at least one .DLL file.
| Code: |
@echo off
cd "c:\Program Files\PICC"
deltree /y DLL
deltree /y Examples
deltree /y Devices
deltree /y Drivers
deltree /y ico
del UNWISE.EXE
del Default.mcp
del Suite_CCSPic.dll
del CCSCON.exe
del Readme.txt
del Ccsc.chm
del Ccsc.exe
del ccsuninstall.exe
del install.log
del Checkgdiplus.exe
cd "c:\Documents and Settings\<user name>\Application Data\PICC"
del pcw.ini
del ccsc.ini
cd "c:\Program Files\PICC"
dir
pause
|
It's not perfect. It doesn't check for the existence of files or directories
before attempting to delete them.
Edit:
Actually, XP doesn't come with deltree.exe. You have to download it from
the web. For example, this site has it:
https://www.raymond.cc/blog/download/did/1707/
Put it in the c:\Windows directory. Then the above batch file will work.
Last edited by PCM programmer on Tue Aug 19, 2014 1:52 pm; edited 1 time in total |
|
 |
nando88
Joined: 25 Aug 2013 Posts: 28
|
| CCS & MPLab |
Posted: Tue Aug 12, 2014 10:36 am |
|
|
Do I have to install mplab in order to use this code you provided?
From what I read, you used the mplab plugin.
I tried to compile the code only using ccs, but it gave me an error.
I also need to make this work for windows 7, 8, 8.1,etc.
Please tell me how to do this.
Thanks in advance! |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 12, 2014 11:06 am |
|
|
| Quote: | | Do I have to install mplab in order to use this code you provided? |
I assume you're talking about the code that is linked to, in my previous
post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=52722&start=19
No, MPLAB isn't required. The CCS IDE should work fine.
| Quote: | | I tried to compile the code only using ccs, but it gave me an error. |
You've got to tell us what the error is. Post the error messsage.
| Quote: | | I also need to make this work for windows 7, 8, 8.1,etc. |
I can't help you with that because I'm a retro person still stuck on XP. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19993
|
|
Posted: Tue Aug 12, 2014 1:46 pm |
|
|
However the CCS side, doesn't change with XP, Vista, W7, 8, etc..
It's just the different .inf file needed when the device is first attached to the system.
Everything else remains the same. |
|
 |
nando88
Joined: 25 Aug 2013 Posts: 28
|
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 12, 2014 3:12 pm |
|
|
OK, I see what you mean. To fix this problem, go to the CCS Examples
directory, and find ex_usb_common.h, and copy that file into your
project directory. Then it should compile OK. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19993
|
|
Posted: Tue Aug 12, 2014 3:17 pm |
|
|
Are you using MPLAB?.
If so, only the 'main' source file wants to be in the 'source files' tab.
It's behaving as if you are trying to compile 'usb'h' on it's own (so no #device exists).
MPLAB will try to compile _all_ files in the source tab....
Other reason would be that you are including the file too early in the main file. |
|
 |
nando88
Joined: 25 Aug 2013 Posts: 28
|
| another error |
Posted: Tue Aug 12, 2014 9:47 pm |
|
|
I already copied the example to my working directory, but now I'm having another error:
https://www.mediafire.com/?0sqyy6rf5z7ggw8
Please tell me how to fix this error.
Thanks! |
|
 |
nando88
Joined: 25 Aug 2013 Posts: 28
|
| Compiler used |
Posted: Wed Aug 13, 2014 9:23 am |
|
|
I'm not using mplab, I'm only using ccs. The thing is I still don't know how to fix this error that says device required in the usb.h.
Can someone please help me out?
Thanks in advance! |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
nando88
Joined: 25 Aug 2013 Posts: 28
|
| Solution |
Posted: Wed Aug 13, 2014 2:51 pm |
|
|
I just figured out what was the problem. I checked the files I was using, and for some strange reason it was using a different directory than the one in which the project resides in. I just closed the application and opened the app again, and it compiled just fine.
Thanks for all you help!
I have another question.
I made the led blink on a dev board I purchased and I think that I'm doing something wrong in the code, because it delays 4 times what its supposed to delay.
| Code: |
#include <18F4550.h>
#fuses HS,NOWDT,NOPUT,NOLVP,BROWNOUT,NOCPD,NOWRT
#use delay(clock=5000000)
void main()
{
while (TRUE)
{
output_HIGH(PIN_A3);
delay_ms(1000);
output_LOW(PIN_A3);
delay_ms(1000);
}
|
Can someone please tell me how to fix this problem?
Thanks! |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 13, 2014 4:12 pm |
|
|
Well, what's your crystal frequency ? The #use delay(clock= xxxx)
should match your crystal frequency, for the #fuse settings shown. |
|
 |
nando88
Joined: 25 Aug 2013 Posts: 28
|
| Crystal Frequency |
Posted: Wed Aug 13, 2014 5:48 pm |
|
|
| I use a 20 mhz crystal, but for the app to work correctly, I used a delay(clock=5000000). I changed the delay, and the pic worked faster, and before it seemed to work 4 times slower. |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|