Difficult to write a complete code for microcontroller

Discussion in 'Embedded Systems and Microcontrollers' started by anhnha, Sep 13, 2014.

  1. anhnha

    Thread Starter Active Member

    Apr 19, 2012
    773
    45
    I have some basic understanding of microcontroller, C programming language and did some projects about this. However, I just got a job relating to this and realized that I lack lots of knowledge to write a complete program on my own without copy, paste and edit some sample code from the net.
    My work place doesn't allow to use the Internet so I get depressed and couldn't write a complete code and make it work without searching the net.
    Now I have to study actually how to use microcontroller in detail such as memory map, makefile, set fuse bits, WDT,...
    I use PIC 16 and 18 families and run it on PIC C compiler and MPLAB.
    Could you give some advice and some links/guideline so that I can write the code on my own?
    I am allowed to use datasheet there is lots of concepts that I can't understand.
    PS. I found this page extremely good.
    http://www.mikroe.com/chapters/view/16/chapter-3-pic16f887-microcontroller/
     
  2. adam555

    Active Member

    Aug 17, 2013
    858
    39
    I began with PIC microcontrollers from scratch just a few weeks ago, and couldn't find a good tutorial for C and the PIC16F family. So, I found it really hard at first, but by looking through a lot of different sources -including many questions on this forum- I learnt the basics of how to use each peripheral, and now all I need is the datasheet -mainly as a reference for pins and registers-.

    So that's my advice: learn to use each peripheral in C; it's not that many, so it won't take you long.
     
    Last edited: Sep 13, 2014
    anhnha likes this.
  3. adam555

    Active Member

    Aug 17, 2013
    858
    39
    These 6 short videos playlist explains the main peripherals.

     
    anhnha likes this.
  4. anhnha

    Thread Starter Active Member

    Apr 19, 2012
    773
    45
    Thanks for the advice and tutorial! I will spend some time reading them carefully.
    Also, I find it hard to understand fuse bits, WDT, choosing oscillators. Do you write these yourself?
     
  5. adam555

    Active Member

    Aug 17, 2013
    858
    39
    And this is a full tutorial, also for PIC16F with MPLAB XC. It's an in depth course of 42 videos based on the book: "Designing Embedded Systems with PIC microcontrollers":

     
    Last edited: Sep 14, 2014
    anhnha likes this.
  6. adam555

    Active Member

    Aug 17, 2013
    858
    39
    You have a tool on MPLAB X that generates the fuse bits for you specific to whatever PIC you are using. In the menu go to "Windows > PIC Memory Views > Configuration Bits"; set them up as you wish, click generate, copy the result in your code, and you're done.

    I didn't need to use the WDT function yet, so for now I can't help you, but I can guide you with the oscillators.
     
    anhnha likes this.
  7. anhnha

    Thread Starter Active Member

    Apr 19, 2012
    773
    45
    Thanks a lot! I will try to digest these tutorials first before moving on. :) It will take some time.
    I spend one all day yesterday reading about oscillator (how it work, how to choose capacitors, resistors) but it is still obscure. I find the language in datasheet hard to understand. I usually consult lots of dictionaries but sometimes I get lost. :confused:
     
  8. adam555

    Active Member

    Aug 17, 2013
    858
    39
    I understand what you mean: the datasheets are better as a reference guide than a place to learn.

    About oscillators, you can use the internal oscillator (which is the simplest option), a crystal, or an RC oscillator (which I guess is the hardest). You choose these options through the configuration register (the fuse bits); as well as whether you want the WDT on or off.
     
    anhnha likes this.
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Microchip has a set of tutorials for the Low pin count dev board. The tutorials are in both assembly and C. It is well worth a download to read these.

    If you are serious about your career then you may actually spend a few bucks and get the kit too. The total is about $75USD.
     
    anhnha likes this.
Loading...