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

data sheets are nothing for ccs c programmer.

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







data sheets are nothing for ccs c programmer.
PostPosted: Sat Nov 07, 2009 4:06 am     Reply with quote

Hi

I am a programmer for 1 year now in ccs c, and today I understood that I just can't work on my own and need to copy codes all the time.
That's because data sheets are for assembler programmers !

For example, if I want to learn one of my pic's protocols, the data sheet will mean nothing to me because its all about sets registers and written for assembler programmers. Nothing will help for c programmer. Nothing.

I don't want registers! I want exactly syntax to all function I write.
And that's why I can't work on my own and need to copy code from the net every time I need something new. I hate that ! And its not just me! People don't look too much on data sheets because setting registers don't help for c programmer. And the controller scheme doesn't help to programing.

The help of CCS c is really nothing. Because I can't read help about a subject and get it into a code. Its a general help not specific syntax!
I am engineer, and not just stupid kid. But I just can't take this help into a code. Its so unclear.

So my question is, where can I find a real guide, that when I need to write for a eeprom or write rs232 I can find the exact code with exact explanation. Not just a general talking ! I need a real source to program!


From where you people take your syntax to do something new ?????


Thanks a lot (all my knowledge is from here anyway).
eskimobob



Joined: 07 Feb 2009
Posts: 40

View user's profile Send private message

PostPosted: Sat Nov 07, 2009 4:34 am     Reply with quote

Probably the best thing to do is find one of the CCS examples that has something relating to what you need to do then examine it and figure out how it works. Cool
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Nov 07, 2009 6:34 am     Reply with quote

Quote:
data sheets are for assembler programers
No. I think, it's wrong in several regards. Microchip issued the data sheets for everyone using
their products, not considering a specific programming tool. As an embedded C programmer, you often need
to know the specific hardware prerequisites of the target platform to solve a specific problem.

Is it possible to have a HAL (hardware abstraction layer), e.g. CCS C built-in functions, that completely saves
you from reading datasheets? I can hardly imagine.

Obviously, there are different concepts in hardware access of embedded C tools. Microchip C18/C30 and HI-TECH
are providing little hardware abstraction, CCS in contrast is trying to hide hardware details. Both ways have advantages
and disadvantages. Treading the CCS path, you'll sometimes wonder, what's actually happening in the hardware.
Because of the brief documentation, you have to answer the question yourself, but if you managed to understand,
you can get excellent results with the CCS tools.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sat Nov 07, 2009 7:14 am     Reply with quote

What is the problem with setting and reading registers with C? With any other uP C compiler you have to do that all the time. CCS spares you sometimes, but can't always.
_________________
The search for better is endless. Instead simply find very good and get the job done.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 07, 2009 11:35 am     Reply with quote

Post one example (a short one) about one module, such as ADC or PWM,
etc. Explain how you're lost. Then we'll tell you how we do it.
ron
Guest







example
PostPosted: Sun Nov 08, 2009 5:46 am     Reply with quote

Thanks for responds.

For example- I know how to do a pwm, and did it so many times in a complex systems, but, don't really understand what exactly the timer is doing. How can I do that with another timer, for example- the formula to a pwm ! The only way to know that is go here and ask!
It's not appear anywhere !

Another example: I need now to operate 4 channels pwm. How ??? where??

This information is missing. Without you I didn't have a job now !
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 08, 2009 1:39 pm     Reply with quote

Are you talking about hardware PWM ? The formula for the PWM
frequency is in every PIC data sheet (that has a CCP module).

Mostly, if you don't know the answer, you have to learn how to use
Google to search for the information. Microchip has a large number
of tutorials and application notes available. Use Google to search it.
Example of a Google search string:
Quote:
site:microchip.com PWM PR2 period


Sites like http://www.embedded.com have a large number of tutorials.
Use Google to search the site. Example of a search string:
Quote:
site:embedded.com PWM Timer period
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon Nov 09, 2009 12:01 am     Reply with quote

Well in this universe you can't learn just one way of doing things then expect it to give you access to solutions in every conceivable circumstance. PIC devices are by design focused on hardware. Yes they aren't even soldered to a PCB when most of us see them for the first time. The pins are specific
MCLR needs to be tied high and A0 is often open drain certain pins are assigned to receive the crystal oscillations etc. Knowing C visual basic or whatever isn't enough on a PC you still have to find the hardware on/off button. Now the PIC requires a bit more curiosity what with registers fuses and interfaces like I2C rs232 SPI PWM and so on but that's what makes the devices useful.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Mon Nov 09, 2009 3:40 am     Reply with quote

FvM and PCM Programmer are completely correct.

I use datasheets ALL the time and if you are doing embedded programming whether in Assembler, C or any other language you had better learn to read and understand them.

You will eventually try to drive a chip in your hardware that you cannot find a library for, sure people will help you develop one on forums like this but if you come here and ask someone else to read the datasheet then write the software for you you will find that the help starts to disappear.

I currently use CCS for PIC C but I also am working with Embedded Windows CE hardware writing code in C#, .net but I have had to resort to reading the datasheet and writing code in C (dlls) to control the hardware. The other option is of cause to pay the developers of that hardware to write it for me, but then why am I being paid ?

And before anyone else says it, .net for embedded programming, yes I know, this is why I have had to resort to C for some stuff.
Guest








PostPosted: Mon Nov 09, 2009 1:24 pm     Reply with quote

You can't do embedded C programing unless you're intimately familiar with the chip you're using. That means familiarity with all the chips register, I/O's, timers etc. That in turn means also being a software as well as a hardware engineer.

While C is higher up than assembly one has to know the nuts and bolts of the chip. That's why it's usually much easier for assembly programmers to go into C than the other way around.

Formula for doing it:
Learn C
Learn the chip's specs
See how others have solved similar problems in this forum.

If you don't follow these simple (but time consuming) steps it will come back and haunt you.

Cheers
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Nov 09, 2009 5:33 pm     Reply with quote

You also may wonder, why CCS C has an option to install all PIC datasheets with the compiler? Obviously they don't think, that the compiler manual is a sufficient work basis.

Anyway, I understand some of Ron's thoughts. A problem e.g. with the PWM manual chapter is, that it's implicitely talking of PIC hardware details (e.g. 8/10 bit resolution for duty cycles) without naming them. If you're not familiar with this hardware details, you'll need some time to acquire what's omitted here.

You can imagine e.g. an overview, which built-in function is actually valid for a particular PIC. Reading the manual, it's not obvious, why set_pwm5_duty() is not working with your chip...
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Nov 09, 2009 10:05 pm     Reply with quote

I have to agree with the sentiment that this isn't Window or Linux or insert_big_os_with_lots_of_abstration_to_hard_here.

This is a microcontroller. You are the king of the OS it runs (if you can even call it an OS.. so to speak).

So it's really a different ball game. I have worked with lots of talented programmers in the past that know absolutely zilch about hardware.

They are fantastic programmers, but they don't know hardware. They are not firmware programmers.

It's really 2 different worlds. Learn to love your datasheets.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
eskachig



Joined: 27 Mar 2009
Posts: 8

View user's profile Send private message

PostPosted: Wed Nov 25, 2009 6:01 pm     Reply with quote

ron wrote:
I am a programmer for 1 year now in ccs c, and today I understood that I just can't work on my own and need to copy codes all the time. That's because data sheets are for assembler programmers !
Actually no, when it comes to firmware data sheets are simply for everybody, and it doesn't even cover the actual assembly instruction set anyway. A data sheet will tell you what your chip can and cannot do, which timeouts you need to use, etc. It's true that if you use CCS you probably won't be setting any registers directly, but without a data sheet you will be totally lost.

Quote:
For example, if I want to learn one of my pic's protocols, the data sheet will mean nothing to me because its all about sets registers and written for assembler programmers. Nothing will help for c programmer. Nothing.
Without the data sheet you don't know how many timers you have or what kind they are, how many CCP modules, how long you need to wait for an ADC reading, etc. Without that knowledge you don't know how to use CCS's built in utilities.

Quote:
I don't want registers! I want exactly syntax to all function I write.
And that's why I can't work on my own and need to copy code from the net every time I need something new. I hate that ! And its not just me! People don't look too much on data sheets because setting registers don't help for c programmer. And the controller scheme doesn't help to programing.
An intimate understanding of the controller scheme is integral for any kind of non-trivial firmware programming, doesn't matter whether you use assembly or CCS.

Also, the CCS manual has all of the API spelled out clearly. It's not always up to date, but certainly you should have no trouble figuring out the syntax.
Quote:
The help of CCS c is really nothing. Because I can't read help about a subject and get it into a code. Its a general help not specific syntax! I am engineer, and not just stupid kid. But I just can't take this help into a code. Its so unclear.
What is so unclear? Are we talking about the same manual here? Check your /PICC directory - there should be a file called Ccsc.chm, it has the description of the CCS's particular flavor of the C language and an overview of built in functions, their usages, parameters, etc.

Quote:
So my question is, where can I find a real guide, that when I need to write for a eeprom or write rs232 I can find the exact code with exact explanation. Not just a general talking ! I need a real source to program!
CCS ships with a lot of examples which you can look through for specifics - certainly writing to eeprom and rs232 is covered. Look for the "Examples" directory in /PICC.

Quote:
Thanks a lot (all my knowledge is from here anyway).

This has been en enormously useful forum for me as well, one of the best technical communities on the net imo.

ron wrote:
For example- I know how to do a pwm, and did it so many times in a complex systems, but, don't really understand what exactly the timer is doing. How can I do that with another timer, for example- the formula to a pwm ! The only way to know that is go here and ask!

This is actually a great question because it can illustrate a possible development path.

Step 1: You need to know what PWM is, a brief explanation can be found here:
http://www.embedded.com/story/OEG20010821S0096

Step 2: Your PIC may well have special modules for performing PWM. This is exactly what the datasheet is good for! For example, my PIC18f7822 has 5 separate CCP modules that I can use (and the data sheet shows which pins and timers they connect to). Now that I know which CCP module I want I can use the built in CCS functions to set them up, after looking up the function information in the CCS C manual and figuring the timer parameters (this also is a question for the data sheet).

Step 3?: If I cannot use the built in modules for some reason, you can run a pwm cycle off any timer (usually as a simple timer interrupt). You shouldn't need a formula for this at all, the implementation is dead simple if you understand what the PWM cycle actually is. I mean, a 50% duty cycle would be, for example, 5 timer intervals where an output is high followed by 5 timer intervals where an output is low, and on and on (numbers are purely examples). There are a million ways to set something like this up, and most of them can fit into 10 lines of code.

Quote:
Another example: I need now to operate 4 channels pwm. How ??? where?? This information is missing.


Building on what I said earlier:

a) use built in CCP modules with CCS functions to set up PWM on 4 of the available CCPs.

or

b) use a regular timer and do the PWM by hand, except instead of one output pin and duty cycle you need to keep track of 4. Once again, fairly trivial.

You need to get a handle on the relevant documentation. In this case you can find most of the info you need in the CCS C manual, CCS examples, and the data sheet for your PIC. You also need to grasp how the information in the datasheet corresponds to the CCS libraries and their parameters. After you are comfortable with this process you'll be able to see solutions a bit easier.

Understanding the available documentation and knowing where to look something up is crucial in any form of software development.
Guest








PostPosted: Tue Dec 01, 2009 5:00 pm     Reply with quote

Hi,

Why not use snippets of the Microchip asm examples as is?
One of the reasons I chose CCS was the excellent & simple use of in-line assembly.

Some final words of comfort;
We are lucky, lucky guys, considering the huge amount of PIC & C-examples available!

I'm also working with GSM-hardware that's very nice, but has appalling documentation and "examples" that leave you slightly dizzy for 45 minutes.. Think "manual for chinese DVD-player translated to Norwegian and back again".. Smile

We are lucky, lucky guys!

/BdeB
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Dec 02, 2009 9:51 am     Reply with quote

I rely _heavily_ on data sheets whenever I'm doing a project. Virtually every component will have some sort of data sheet. Some are better than others but I use them a lot, especially for PICs. You need to know what 'hardware' is inside first before you can control it properly.

For example, using a timer. Some timers have a pre-scaler and a post-scaler. Some just have one scaler and not both. Some timers are 8-bit and others are 16-bit. I/O pins have multiple uses and, depending on how you set things up, different hardware will be enabled/disabled.

There might be a lot of ASM examples given in the data sheet. I'm not an ASM programmer. I've never known how to program in assembly and, quite frankly, I don't want to learn. Registers are wonderful! They let you have direct access to the 'guts' of the PIC. It's not hard to monitor/manipulate them and can come in handy. Take the i2c_isr_state() command used in a slave. Instead of using that command I monitor the register, directly, instead.

Don't be intimidated by the PIC. I've used various code that has been posted here. We're able to access registers for a reason, because they can aide in controling/monitoring what's happening inside.

Experiment!!!

Ronald
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