Learning c, is this a good place?

Thread Starter

prophoss

Joined Feb 26, 2019
36
Usually I like to ask , well not dumb, questions but stuff that may seem obvious. Mainly I just want clarification to make sure I understand what I just learned. Is this a good place for that? Not suggesting that y'all can't or even won't, but this forum is not really meant for programming specifically. I found this place while I was messing around with my atmega 328p, ya know the arduino. I was starting to learn embedded programming, but have since stopped while I learn c a bit more formally. If anyone has a better place for these kind of questions please let me know. Thanks ahead of time.
Brian Cooper
 

Papabravo

Joined Feb 24, 2006
22,082
There are all kinds of knowledgeable people here. The way it works is you pose a question, with supporting material showing some effort to understand what you have read or what you've encountered in an embedded programming context. We can guide you to resources or examples that will help you understand what you are looking at. This is probably a better place to do that than one that is concerned with programming in the context of an OS and massive resources.
 

jpanhalt

Joined Jan 18, 2008
11,087
In another thread, the TS said,
I appreciate all the responses. Ok so far I am hearing read the data sheet. fair enough, but is that all you can do?
I should have been a bit more specific about what my problem is. I understand about DDR and PORT even PIN thanks to sparkfun going deeper series. It is when I start attempting to use the internal clock and interrupts that I get lost quickly. I will go back and read a bit closer about the TCCR and OCRA stuff. Thanks again.
In your 4 posts to date, it seems you recognize the need to read technical support documents. Have you actually done that? What have you read? How many times have you read it? Studied it? Tried it?

When someone has questions, members here have always responded despite how vague those questions may be. However, it is still the poster's responsibility to clearly formulate its questions and respond with clarifications as needed. We cannot do that for you, and your follow up has been minimal at best.

Take this example from the present thread,
prophoss said:
That is why I asked. Could you suggest another site a bit more geared in that direction?
Papabravo clearly described the process here, so what do you mean by "in that direction." Seems more than a bit non sequitur.

If you want to try a place that might be more to your liking, have you considered StackExchange (https://softwareengineering.stackexchange.com/). You could try posting the crux of this thread's question there. Please let us know how it works out.
 

Ian Rogers

Joined Dec 12, 2012
1,136
The best way to learn is by doing and failing... I suggest learning C on a PC as the tools are free.. You can run TurboC in a DOSBox and debug as well.. I used this while I was learning... The newer compilers are C/C++ so you are forced into object code ( well not forced, but all tutorials are mainly C++)… The compiler can be downloaded on the net..

I used to use Borlands 4.5 for windows applications ( again free ).. Once you have written several program and succeeded you can get your head around embedded Micro's.... Similar but far lower level..

If you post code here, there are many C coders that will guide you..
 

Papabravo

Joined Feb 24, 2006
22,082
That is why I asked. Could you suggest another site a bit more geared in that direction?
As a matter of fact -- I cannot. I used to belong to four or five, but that was too time consuming and I have settled on this one as a "one size fits all" solution.
 

Thread Starter

prophoss

Joined Feb 26, 2019
36
I don't think I'll be posting in stackoverflow any time soon. It is not what I'd call beginner friendly. I have been watching Mike Dane on YouTube and coding along. I've gotten as far as switch statements. There. The thing is it seems like a lot of the stuff I'm learning doesn't exactly fit in a forum like this. But, many other forums are less than kind when you ask simple questions.
 

mvas

Joined Jun 19, 2017
539
If you have any questions about programming in C, just ask, you will get a reply.
Don't forget to use [ code ] tags.
This is the forum for software engineering and programming languages: C, C++, C#, Fortran, Java, Matlab, etc.
 

nsaspook

Joined Aug 27, 2009
16,322
I don't think I'll be posting in stackoverflow any time soon. It is not what I'd call beginner friendly. I have been watching Mike Dane on YouTube and coding along. I've gotten as far as switch statements. There. The thing is it seems like a lot of the stuff I'm learning doesn't exactly fit in a forum like this. But, many other forums are less than kind when you ask simple questions.
Sure it fits a forum like this.

C was designed to control low level hardware and provide a HLL computer abstraction.

For example 'switch' (a computed goto equivalent) is a work horse in embedded C.

C:
/*
* parse received stream and response codes for host operational state and
* equipment model types
*/
GEM_STATES secs_gem_state(uint8_t stream, uint8_t function)
{
    static GEM_STATES block = GEM_STATE_DISABLE;
    static GEM_EQUIP equipment = GEM_GENERIC;

    switch (stream) { // from equipment
    case 1:
        switch (function) {
#ifdef DB2
        case 1:
#endif
        case 2:
            if (block != GEM_STATE_REMOTE)
                StartTimer(TMR_HBIO, HBT); // restart the heartbeat

            block = GEM_STATE_REMOTE;
            V.ticker = 0;

            break;
            //#ifdef DB2
        case 13: // parse equipment model from comm request response
            switch (V.response.ack[4]) {
            case 'V':
                switch (V.response.ack[5]) {
                case 'I': // VII80A for Varian viision 80 non-plus
                    equipment = GEM_VII80A;
                    break;
                default:
                    equipment = GEM_GENERIC;
                    break;
                }
                break;
            default:
                equipment = GEM_GENERIC;
                break;
            }
            block = GEM_STATE_COMM;
            V.ticker = 15;
            break;
            //#endif
        case 14:
            block = GEM_STATE_COMM;
            V.ticker = 15;
            break;
#ifdef DB2
        case 15:
#endif
        case 16:
            block = GEM_STATE_OFFLINE;
            V.ticker = 0;
            break;
#ifdef DB2
        case 17:
#endif
        case 18:
            block = GEM_STATE_ONLINE;
            V.ticker = 0;
            break;
        default:
            if (block == GEM_STATE_DISABLE) {
                block = GEM_STATE_COMM;
                V.ticker = 15;
            }
            break;
        }
        break;
    case 5:
        switch (function) {
        default:
            block = GEM_STATE_ALARM;
            if (V.ticker != 45)
                V.ticker = 15;
            break;
        }
        break;
    case 9:
        switch (function) {
        default:
            block = GEM_STATE_ERROR;
            if (V.ticker != 45)
                V.ticker = 15;
            break;
        }
        break;
    default:
        if (block == GEM_STATE_DISABLE) {
            block = GEM_STATE_COMM;
            V.ticker = 45;
        }
        break;
    }

    V.e_types = equipment;
    return(block);
}
 

MrSoftware

Joined Oct 29, 2013
2,273
There are forums all over the place. This is a good one as you get guys here who code and work with hardware, which is useful for embedded stuff, and it's a friendly crowd by internet standards. If you get stuck, google your question and that will very often either land you the answer or a great place to post the question.
 

Thread Starter

prophoss

Joined Feb 26, 2019
36
Oh yes Google knows me well. I appreciate the great responses. When I get home I'll be looking over that code nsaspook was kind enough to provide. My goal, so far, is to learn embedded programming. That is why I'm taking the time to learn c right now. I'd love to eventually get a job doing something like that. Thanks again.
 

nsaspook

Joined Aug 27, 2009
16,322
Oh yes Google knows me well. I appreciate the great responses. When I get home I'll be looking over that code nsaspook was kind enough to provide. My goal, so far, is to learn embedded programming. That is why I'm taking the time to learn c right now. I'd love to eventually get a job doing something like that. Thanks again.
Don't look too hard at the function example for insights as it's only a fragment of a complete embedded program and system I'm building.
https://forum.allaboutcircuits.com/threads/secs-ii-host-using-a-pic18f57k42.157503/
 

JohnInTX

Joined Jun 26, 2012
4,787
I've seen some good results using quickie online compilers like this one. You can try new constructs and get immediate feedback without the hassles of a particular operating system or OS.
https://www.tutorialspoint.com/compile_c_online.php

I'm kind of a dead-trees guy so prefer a real book. K&R 2ed edition, Software Tools by Kernighan and Plauger are oldies but goodies but there are lots of good online references, too. Find one you like and drill down into it.
https://en.wikibooks.org/wiki/C_Programming

Lots of colleges and universities publish their texts online as well.
http://www-ee.eng.hawaii.edu/~tep/EE160/Book/
spacecats.mit.edu/contestants/lectures/6.270_c_lecture.pdf

It's just my opinion but I would avoid hobby sites like instructables and the like. While there is some good stuff there, there is also a wealth of examples of bad programming.

If you have a specific question on a C construct post away, we can help.

Once you have a handle on the language, you can see how it is adapted to run on a bare-metal microcontroller. We can help with that, too.

Finally, don't overlook the fact that problem solving skills are more important than the language itself IMHO. There have been many instances here where someone asks for help with programming in some language but is incapable (or unwilling) to actually think about analyzing the problem, breaking it into parts then implement a step by step approach to a solution. Only then can you code it.
Remember:
Planning and design are 90% of programming. Coding and getting it debugged is the other 90% ;)

Good luck and welcome to AAC!
 

dl324

Joined Mar 30, 2015
18,327
I was starting to learn embedded programming, but have since stopped while I learn c a bit more formally. If anyone has a better place for these kind of questions please let me know.
It depends on your background and how you learn. My first preference would have been private tutoring, then small class instruction.

I learned the bulk of C in a 5 day, 8 hours a day small classroom setting; then refined my understanding by using it. After learning more than a dozen languages this way, I'd never consider doing it the more traditional way again.
 

Thread Starter

prophoss

Joined Feb 26, 2019
36
It's not too bad actually. I get the gist of what is going on. Nsaspook was showing me the switch codes he is using which I appreciate. I know better than to try and figure it all out just from that snippet. Having said that isI like to be able to write stuff like that.
 

nsaspook

Joined Aug 27, 2009
16,322
It's not too bad actually. I get the gist of what is going on. Nsaspook was showing me the switch codes he is using which I appreciate. I know better than to try and figure it all out just from that snippet. Having said that is like to be able to write stuff like that.
I guarantee there is little special skill involved. It comes from

"99% perspiration and 1% inspiration"
Thomas Edison

There is a big difference between hardware engineers (that studied Computer Engineering) that program and software engineers. I'm not a software engineer.
 

Thread Starter

prophoss

Joined Feb 26, 2019
36
I'm presently working on a computer science degree. I'm just trying to decide which direction to go. I'm leaning toward the lower end of the stack. It just makes more sense to me for some reason. I'm really thinking about embedded programming, but that is more of a specialized field I think.
 
Top