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 support@ccsinfo.com

Making USB work with PIC18F45K50

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



Joined: 31 Dec 2005
Posts: 32

View user's profile Send private message

Making USB work with PIC18F45K50
PostPosted: Tue Aug 27, 2013 9:54 am     Reply with quote

Hi, I'm trying to make USB CDC work with this PIC because it's a cheap and good replacement for PIC18F4550. It's not working. I'll list everything I did so maybe anyone has new ideas about what can be wrong:

1) Oscillator setup

I'm using a 12MHz external osciillator, so I set up:

Code:

#FUSES PLL4X                   
#FUSES PLLEN
#FUSES NOCPUDIV
#FUSES ECM


2) Porting of existing libs

I looked at the CCS provided code and seems that only pic18_usb.c needs modifications. It was a lot of #define's based on the exactly PIC you're using. I decided to create a new #define mimiking 18F4550 (because it seems to be the most similar PIC amog the supported ones). So I did:

Code:

#elif ((getenv("DEVICE")=="PIC18LF45K50") || (getenv("DEVICE")=="PIC18F45K50")) 
 #define __USB_45K50__
 #define USB_TOTAL_RAM_SPACE  ((unsigned int16)0x400)
 #define USB_RAM_START  0x400
 #define USB_NUM_UEP 16
 #define USB_LAST_ALLOWED_ENDPOINT  16


Then I went to the registers adresses:
Code:

#elif defined(__USB_45K50__)
   #byte UFRML   =  0xF68
   #byte UFRMH   =  0xF69
   #byte UIR     =  0xF65
   #byte UIE     =  0xF64
   #byte UEIR    =  0xF67
   #byte UEIE    =  0xF66
   #byte U1STAT   = 0xF61
   #byte UCON    =  0xF60
   #byte UADDR   =  0xF63
   #byte UCFG    =  0xF62
   #define  UEP0_LOC 0xF6A


They're completely diferent from the PIC18F4550 map. I looked the datasheet to get the correct adresses. I looked them to see if the same bits existem in the same places and found no great diferences (most of them related to the external phy support that's missing in this new processor and the streaming parallel port that's also missing).

Finally I did also this:
Code:

#if defined((__USB_4550__)||(__USB_45K50_))
 #define __USB_UCFG_UOEMON  0x40


Anyone has new ideas? Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19399

View user's profile Send private message

PostPosted: Wed Aug 28, 2013 12:43 am     Reply with quote

Hm.
Used this chip myself, and didn't have to change anything. Support was added in February.

They don't directly allocate the memory addresses, but use getenv to get them for this chip. So:
#byte UFRML = getenv("SFR:UFRML")
#byte UFRMH = getenv("SFR:UFRMH")

etc..
They don't actually define UEP0_LOC for this chip (alters the way the driver behaves).
Maybe something is wrong here.

You don't show your clock rate?. Have you tested this?. Always start by verifying the chip is running, and at the right rate - saves a lot of wasted time later....

They don't do any TRIS operations for the pins on this chip (they aren't shared with GPIO operations).

Obvious comments apply about good smoothing on Vusb. How are you generating this?. Using 5v, and the internal regulator, or are you generating this yourself?

Best Wishes
dmendesf



Joined: 31 Dec 2005
Posts: 32

View user's profile Send private message

PostPosted: Wed Aug 28, 2013 11:50 am     Reply with quote

Hi, I wrote about it to CCS and they told me that this PIC was supported. I was using V4.141 so I installed V5.011 and made a very simple program at V5.011 using USB with this PIC and it works (with a minor flaw that pic18usb.h / pic18usb.c doensn´t recognize PIC18LF45K50, only PIC18F45K50, but that´s easy to fix). I concluded that I have no hardware problems.


So I copied back pic18usb.h / pic18usb.c and 18F45K50.h back from V5.011 to V4.141 and it first gave me a strange error about the fuse "#FUSES MCLR" not being recognized... I commented it out and then it compiled, but the program doesn´t work.

I´m still looking at it, but seems that for this PIC i´ll have to use V5... Sad
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