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

PIC16F1938 setup in CCS?

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



Joined: 26 Apr 2011
Posts: 13

View user's profile Send private message

PIC16F1938 setup in CCS?
PostPosted: Tue Feb 28, 2012 5:30 am     Reply with quote

Hello All!

I have a PIC16F1938. I want to use the RS232 and the CCP3(as a PWM) "at the same time". How can I diable the CCP3 on port C6 and enable on B5?
Is this possible?

Thanks for the helps,
Stygian
temtronic



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

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 6:42 am     Reply with quote

What does the datasheet say about those peripherals ??
Stygian



Joined: 26 Apr 2011
Posts: 13

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 6:54 am     Reply with quote

The datasheet says:

"Pin functions can be moved using the APFCON register."

How can i use APFCON in CCS?
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

APFCON register
PostPosted: Tue Feb 28, 2012 7:40 am     Reply with quote

You should not have to drive APFCON directly.

All the necessary syntax etc. is supposed to be in the 16F1938.h file.

For a newish chip, CCS may not have got round to it.

In that case, you contact them, if you have a valid licence.

As a work round, you can create a definition which includes the register address so that you can write to it directly.

It's not recommended to write directly to registers as your code is not then very portable. You may also find yourself with conflict issues.

Mike
Stygian



Joined: 26 Apr 2011
Posts: 13

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 8:04 am     Reply with quote

Dear Mike!

You mean i can call it from the .h file? Cause I found someting in it:

Code:

[b]#define CCP3_B5             0x100[/b]


So I only have to define it in the main.h?

Thanks,
Stygian
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 9:33 am     Reply with quote

Sorry, I think we may have got our lines crossed.

When you compile for a PICxxFxxx you do a #include <xxfxxx.h> at the top of your program.

I believe the xxfxxx.h file tells the compiler which instructions are valid for the device you are using.

You can read the .h file with say notepad. When you look at the file you will find ALL the valid options for your chosen processor. It''s all there in plain text. I find that CCS is not entirely consistent with its syntax across all devices. (Underscores etc appear in random places.) The right .h file gives you the exact form for your device.


You originally asked about APFCON

From the data sheet the APFCON is at address 0x11D.

So, you put something like this near the top of your program

#byte APFCON = 0x11d

You can then control APFCON directly as though it were memory.

You may have to play with some other registers to get the result you want. Like I said, you may get some register interaction. The normal CCS method usually looks after such things.

I use MPLAB SIM which allows me to observe what my code has done to the registers.

I don't have a current licence, recent compiler, or 16F1938's so can't help you with specific detail.

I hope I've given you a guide.

Mike
Stygian



Joined: 26 Apr 2011
Posts: 13

View user's profile Send private message

SLOVED
PostPosted: Wed Feb 29, 2012 5:07 am     Reply with quote

Thank You Mike!

You give Me the guide what I need Smile.
Thank you once again!

For thoes who want someting like this I post it here:

Code:
#byte APFCON = 0x11d //use datasheet for details
void main()
{
APFCON = 0bxxxxxxxx; /* The "x" is 0 or 1 please use the datasheet for      configuration. In my case  I have to use this config: APFCON =   0b01000000;*/
//Your source code from here or other configuration options...
}


Best Regards,
Stygian
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Wed Feb 29, 2012 9:47 am     Reply with quote

Be aware of the fact that the .h file may NOT list all the options for a particular processor. I ran into this a while back with the 18F14k22 - the options specified in the data sheet to set the voltage reference for the A/D converter were NOT all listed. I did notify CCS of the problem and they acknowledged my information, but I have no idea if they have fixed it yet (they had not last time I looked and I don't have the current compiler). I ended up setting the configuration register myself (I wanted to use the internal reference in that chip).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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