CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB Serial port communication for pic18f2550

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

USB Serial port communication for pic18f2550
PostPosted: Thu Dec 25, 2014 6:04 pm     Reply with quote

I was able to make my application work with the help I received in this forum, but that was when I was using the pic 18f4550.
Now I'm using a dev board with the pic18f2550, and I changed the include in my code, but when I install the driver, I get error code 28.
If someone could please help me fix this problem, I would be so grateful.
I will leave the code I'm using in this link:
http://www.mediafire.com/download/igswpdai4padduk/Working_Code_-_Pic18f4550.zip
This is the code that I used to get my app working with the pic18f4550.
I just need to be able to use this same code, but with pic18f2550.
The only thing is that in order for me to upload this code to my dev board, the hex file can't have any comments in it, so I have to erase the last 2 lines in this file. I really don't know if this makes any difference.
Thanks.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 25, 2014 6:27 pm     Reply with quote

First is the HARDWARE correct? 2550 is a 28 pin device not a 40 , so be sure you've got the right pins going to the correct places !!

Second, your 'working code'... does NOT have the first line such as ...
#include <18f2550.h> //PIC header MUST be 1st line in program

... without this, compiler will halt as it doesn't know which PIC you're using !

Since the ONLY differences i can easily see are these two items, try them and see

recode/recompile/retest/report back

hth
jay
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Working code
PostPosted: Thu Dec 25, 2014 6:50 pm     Reply with quote

I know what you mean, when you say there is no include in the main file, but the thing is that it worked fine with the pic18f4550 dev board. I think its because I'm importing the usb_desc_cdc, and the ex_usb_common.
I tried changing the includes in those files, so that I could get this code working for this other dev board, but I get error code 28, when I install the driver.
I'll have to change the output pins, but that is all I can think of.
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Fri Dec 26, 2014 9:01 am     Reply with quote

Not quite.

It's because the usb_common file you have has been modified.

There is an option in this, just after the initial 'remarks', to have a number of different processors selected - section marked 'Begin User Configuration'. You remove the 'rem' for the processor you want to use for a number of 'standard' configurations. The first one, selects the 4550:

Code:

//#define USB_HW_CCS_PIC18F4550     //CCS PIC18F4550 USB Development kit


If this is not remmed, the code sets itself to use the 4550.

You don't want to touch this file at all. Remove it from your includes. This is a set of standard setups for a number of development boards, which you are not using.

Instead, have:
Code:

   #include <18F2550.h>
   #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
   #use delay(clock=48000000)

   //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    AN0
   
   #define HW_INIT() setup_adc_ports(HW_ADC_PORTS)
   #define USB_CABLE_IS_ATTACHED() input(PIN_USB_SENSE)

   #define __USB_PIC_PERIF__  1
#include <usb_desc_cdc.h>   
#include <usb_cdc.h>
//Then your code.


This sets everything up on the 2550, to match the settings for the 4550, with development board, without the LED's and inputs (since you don't seem to be using these).
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Changes made with no success
PostPosted: Fri Dec 26, 2014 10:37 am     Reply with quote

I made the changes you suggested, but I still get the error, when installing the driver provided by ccs.
I get error code 28.
Here is the code:
http://www.mediafire.com/download/8ib2nz7tzq97wgt/Pic18f2550.zip
Any help will be greatly appreciated.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 26, 2014 12:04 pm     Reply with quote

Please post the text surrounding the 'error 28' that you're getting. I downloaded your zip file, and the .err file only has 2 WARNINGs no errors.
CCS list the errors as text in the manual,not by error number so I can't xref 28.


edit: OK I googled ccs c compiler error 28 and got this...
*** Error 28 "C:\Users\Orazio\AppData\Roaming\PICC\Projects\TCPIP Stack\GenericTypeDefs.h" Line 64(28,29): Expecting an identifier
...
So I'm assuming you got something similar
Error 28....*** Error...... Expecting an identifier

???

jay
nando88



Joined: 25 Aug 2013
Posts: 28

View user's profile Send private message

Problem fixed
PostPosted: Fri Dec 26, 2014 6:26 pm     Reply with quote

The problem I had was with the os. It did not allow me to install any drivers.
I just fixed the problem and got my app working thanks to you guys.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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