writing a program on c

Discussion in 'Embedded Systems and Microcontrollers' started by aka-rato, Jul 24, 2012.

  1. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    Hi All

    i have never written a program in my life, now i have to write a program in c.my setup includes MPLAB IDE with MPASM for assembler programs, and MPLAB IDE with C18 (v3.40) compiler for C programs.

    i do not understand this language e.g(TRISD=0; TRISB) what it means.
    Please someone help me with what can i do to understand the language.
     
  2. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    TRISD, TRISB, etc. are names used to refer to parts of the microcontroller, TRIS stands for Tri State Register for that port, this is where you set each port pin as an input or output, example, TRISB=0 basically says, Tri state registers of port B all = 0(meaning they are all outputs, if you set all pins =1, then they are all inputs) then you can use that port like PORTB=0x02, etc....
     
  3. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    Tank u so much. Dont you have any reference that u can refere me to so that i learn more about abbrs.
     
  4. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    There are thousands of sites that have tutorials for C or any other programming language.. Have you ever used Google?
    I HIGHLY suggest you start with "Hello World" and move your way up from there.. Trying to jump in in the middle of code will just confuse/scare you. Start small...work up
     
  5. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    The reason i came here its bcoz google did not give me what i wanted, a link would be better.
    The "Hello World" tutorial is meant for anyone who has no experience in programming applications for the Android operating system, but would like to, and in this case i dont want to know about that, i want to understand electronics programming on the operating systems for the PICs.
    THANK U
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I would suggest you get some lessons to follow. Microchip has a great starter lesson plan here. Get both the "PICkit 3 Debug Express Lessons User's Guide" and the "PICkit 3 Debug Express Lessons Files." Elsewhere you can download the compiler from Microchip (it seems you already have MPLAB).

    While you may not have the hardware to run these projects you can run them in the simulator inside MPLAB. If you can get things to work in the simulator they should also work in real hardware (as long as you have the correct configuration settings so the oscillator works).
     
  7. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    okay thanx let me go through it and then i'll let you know how far it takes me.
     
  8. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    I'm a member over at Electro-Tech, and there are a couple of tutorials that the guys there put together. You can find them here and here.

    Something you'll need to consider--C18 will only work for the PIC18F series chips. It will not work for, say, the 16F628 (a popular learner's chip). What microcontroller do you plan to use?

    The first link I posted is for C18, but the second one is for Hi-Tech C (different C compiler, that works on the 16F series).
     
    aka-rato likes this.
  9. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    huh?? Your google skills ARE weak.. I said NOTHING about android.. Just about every programming language for every "electronics programming" device has a "hello world" example.. "Hello World" is usually the FIRST thing you do in any programming language to get started. From C to HTML..they all have a hello world type beginner tutorial

    Try this
    http://www.lmgtfy.com/?q=pic+c+tutorial
    http://www.lmgtfy.com/?q=pic+hello+world
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Microchip is in the process of unifying all the separate C compilers into one uniform XC8 package. While if you look "under the hood" there may be separate compilers still running for the different families you at least only need specify one tool for most of your C projects.

    It's also a freebie download for the basic versions.
     
    DerStrom8 likes this.
  11. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    When you read someone's post there are two things you can do, either you help or read and leave it for those who will be interested in helping without criticism, and the reason i came here its bcoz i knew there are people with better skills than me...I DID'NT NEED TO KNOW ABOUT YOUR 'GOOGLE BETTER SKILLS'...This forum is for people to help one another about important things, not for people to prove how better or intelligent they are than others. So next time help or keep it to yourself.
     
  12. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    I'll b using the pic18f and pic16f, also pic16c.
     
  13. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Here's that XC compiler: MPLAB® XC Compilers

    MPLAB® XC is Microchip's simple and comprehensive line of compilers that support all their devices.

    Supports all 8-, 16- and 32- bit PIC MCUs and dsPIC® DSCs
    Integrates with MPLAB® X IDE and all Microchip development tools
    Runs on Windows, Linux and Mac OS X
    Different optimization levels to suit your needs with FREE downloads available
     
    DerStrom8 and aka-rato like this.
  14. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    Thank you very much guyz, im sorted..
     
  15. MrChips

    Moderator

    Oct 2, 2009
    12,418
    3,355
    This forum provides generous guidance to those who are willing to help themselves. When you come seeking help be careful on how you criticize others.
     
    absf and DerStrom8 like this.
  16. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    That was extraordinarily rude. If you keep talking like that, don't expect people to keep replying. Members here are generous enough to give you assistance and advice. The comment about your google skills was a side note, and was not meant to be insulting, I'm sure. It was merely a suggestion to do more research on your own, rather than expecting everyone to hand you the answers on a silver platter. Things just don't work that way, even if you're talking to a complete stranger. YOU are the one with the problem, so YOU must be the one to search for the answer. All we do here is point you in the right direction.
     
    absf likes this.
  17. aka-rato

    Thread Starter Member

    May 11, 2012
    58
    0
    Actually i didn't mean to offend anyone, if you can go through the links that was send may be you'll understand why i was offended that was not polite at all, also go back and read my first reply about google.
     
  18. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Actually the OP has a point here. When I see someone here (especially with a low post count) and they ask "where do I find info about X?" I very rarely hit back with a let me Google that for you (though I am known to do that, especially when searching the title of their query yields a wealth of good information).

    WE may know the historical basis for the "Hello World" program, I certainly do as my copy of K&R is on my desk right now. I do not expect everyone else to know these things as they start out. Google can be your friend and your enemy too: just try to search for PIC code for the DMX interface and not get page after page of pictures of some rapper!

    As an "old guy" must of my purpose here is to lead the next crop of designers to a level of understanding where they answer their own questions. A kind helping hand is usually called for.

    Also, everyone should understand that many people here do not use English as their first language, so their usage may seem a bit course to those who are. That's life, deal with it.

    However, as an aside to the OP: never bite the hand that feeds you. :cool:
     
    aka-rato likes this.
  19. MrChips

    Moderator

    Oct 2, 2009
    12,418
    3,355
    This is not something one would learn from posting on a forum.

    TRISD and TRISB are not part of the C language syntax. These are specific to Microchip PIC processors.
     
  20. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    No, certainly not. Some time ago I used assembler for PICs, and did not consider C because it is difficult to start off.

    Then at some point of time I wanted to use USB. There was this 18f13k50 chip, and a USB source code supplied by Microchip. It was for 14k50 only (which has double RAM). I worked many hours at it, making changes, and trying to make it work. Then I changed the 6 MHz ceramic resonator to 12 MHz crystal, and then it worked!

    I did it without any guidance or help.

    Certainly it is possible to learn a programming language only by using web sites. I did learn javascript this way.

    Otherwise it might be required to buy a book about embedded C, aimed at beginners. And some generic literature about the subject of computer programming might be beneficiary as well.
     
Loading...