View previous topic :: View next topic |
Author |
Message |
BrokenRotor
Joined: 28 Mar 2012 Posts: 5 Location: Minnesota
|
How do I create a header file for the PIC16F1507? |
Posted: Wed Mar 28, 2012 5:58 pm |
|
|
Hello everyone. Just joined here today. I also just recently bought the PCM compiler. It list the 16F1507 as not tested and the header file for it does not have any of the PWM functions included. I would like to make my own but I am not sure how to do this. I have never done it before. I'm sure that shows how green I am, but we all gotta start somewhere.
I'm sure I left out something needed so you can help. Please let me know.
Thank you for your help.
Steve _________________ Never give up, just keep throwing more money at it.. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Wed Mar 28, 2012 6:43 pm |
|
|
I have 4.131 PCWHD and don't have any PWM values in the header file either. As far as how to do it yourself, look up the pertinent SFR address in the memory organization table and setup some variables.
For example:
Code: |
#byte TMR2 = 0x01A
#byte PR2 = 0x01B
#byte PWM1DCL = 0x611
#byte PWM1DCH = 0x612
#byte PWM1CON0 = 0x613
|
That creates variables and maps them to the actual registers (assuming those addresses are correct). Normally, you can do a little shortcut for portability:
Code: |
#byte TMR2 = getenv("SFR:TMR2")
|
But since your chip is untested, you might get the wrong values.
EDIT: you can also define specific bits:
Code: |
#bit PWM1EN = PWM1CON0.7
|
Those will let you change individual bits if you need.
One you have those variables, you need to make a function and fill it either with C code that uses those variables or assembly that uses those values. If you choose assembly, you can use:
Code: |
#ASM
//assembly code here
#ENDASM
|
As far as what C or ASM code to put, look at section 19.1.9 of the data sheet. It provides step by step instructions.
If you have trouble, post your code up here, but make sure it is a small complete program so we can toss it into a compiler and be able to compile it without changing. Also, tell us your compiler revision. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Wed Mar 28, 2012 7:25 pm |
|
|
If you just bought the compiler tell CCS! They should fix the header for you. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
BrokenRotor
Joined: 28 Mar 2012 Posts: 5 Location: Minnesota
|
|
Posted: Wed Mar 28, 2012 8:04 pm |
|
|
PCM programmer, What I bought is the command line compiler. I do not know what version or how to find out. I just bought it two or three weeks ago.
jeremiah, I think what you posted is what I need. I will try it and see. Thanks!
dyeatman, they already know. They list the part in the supported devices as not tested. I emailed them and they said to make my own header file. That is what brought me to this forum.
Thanks to all of you . I will report back and let you know how it goes. Just might be a couple days.
Steve _________________ Never give up, just keep throwing more money at it.. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 28, 2012 8:27 pm |
|
|
Quote: | I do not know what version or how to find out.
|
Compile a program and then look at the top of the .LST file in the
project directory. Look for a number like this:
http://www.ccsinfo.com/devices.php?page=versioninfo
Or, open a command prompt window and go to the c:\Program Files\picc
directory and run: ccsc +v
It will open a window which shows the version. |
|
|
|