mikroc 8.2 configuration bits

Discussion in 'Embedded Systems and Microcontrollers' started by gehan_s, Feb 15, 2013.

  1. gehan_s

    Thread Starter Member

    Sep 17, 2012
    38
    0
    Please help me set the configuration bits for my pic18F2550 microcontroller. I am using mikroc v8.2 with an external quartz crystal. I tried the default settings with the following code and the timing was way off. BTW the circuit works even without the oscillator (I think this has to do with the default bit setting).

    This is the code that I tried.

    Thanks in advance !!!!!!!!!!!!!!!

    Code ( (Unknown Language)):
    1.  
    2. void main(){
    3.  
    4. TRISA=0;
    5.  
    6. while(1){
    7.  
    8. PORTA=1;
    9. delay_ms(1000);
    10. PORTA=0;
    11. delay_ms(1000);
    12. }
    13.  
    14. }
    15.  
     
    Last edited by a moderator: Feb 16, 2013
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    In the project settings tab, do you have the correct PIC chosen, as well as oscillator ferquency (in Hz), internal or ext?

    Check the help file for external crystal changes.
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,389
    1,605
    If "the circuit works even without the oscillator" you have the config bits set wrong: you have the internal oscillator turned on. "HS" is probably the setting you need for this unspecfied crystal you are attempting to use to work.

    As you have also not specified what frequency you want the PIC to run at we can't help you with other config or register settings you need. You figure these out using the Clock Diagram (Figure 2.1) of the spec sheet. "Where" the bits noted are places is always a pain to find, but the search feature in PDF's helps.

    The compiler needs to know how fast the code is running so the delay_ms() function times correctly. This is set in the same "Edit Project" window as the config settings. "Oscillator Frequency" needs to be
     
  4. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    4 MHz or NTSC colorburst: XT.
    8 MHz or higher: HS.

    6 MHz crystals are rarely used, I do not know XT or HS.

    How does MicroC work? Having an IDE on it's own, or integrated into MPLABX?

    For MPLABX, you can use: WINDOW::pIC MEMORY VIEWS::CONFIGURATION + copy the generated code into the configuration_bits.c file.

    MicroC must have a similar facility.
     
  5. gehan_s

    Thread Starter Member

    Sep 17, 2012
    38
    0
    Thank you all for your replies !!!!!

    The crystal frequency is 4MHz. Sorry I did not know that it was important. I did it in V4.15 with some settings that I found in the net and it works fine. It’s just that in V8.2 the notations are hard to understand.

    Regards
     
Loading...