Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MikroC & SD CARD & PIC18F4520

Status
Not open for further replies.
I'm still having problems initialize the oscillator part.
Any necessary direction register need to be initialized in MikroC ?
 

did you tried building a led blinking program?

when you use pin as input you need to initialize TRIS register as output.. and disable all multiplexed peripherals on that pIN..

---------- Post added at 13:31 ---------- Previous post was at 13:30 ----------

it would be better if you make a simle blinking program.... dont just jump in a very complicated project! that is a suicide... :)
 

Nope, I didnt directly jump into complicated.
Because I having some errors when I do simulation in ISIS by adjusting the config bits of my project oscillator.
 

I use proteus simulation to try see the graph result but there isnt any outputs.
In my code, I didnt put any codes inside, by plainly set out config settings into RC mode.

Proteus Setup Diagram:
Testing_OSC.JPG

Oscillator Config Bits
OSC_setting.JPG
 

Hi, guy

Does anyone know how to setup internal PIC18F4520 oscillator in MikroC Pro ?

I'm still aint get anything progress on Proteus simulation working.

Can anyone can suggest ?

Thank you.
 

To set the clock frequency on a MCU in Proteus, right click on the MCU in the design and select "Edit Properties" and simply enter the correct frequency in the "Processor Clock Frequency" form slot.

Proteus does not seem to require any oscillator circuitry in the design as long as the entered value is correct.

To set the configuration bits in MikroC for an internal oscillator, simply click on the "Oscillator Selection" menu and select "INTOSC - RA6 as I/O, RA7 as I/O".

BigDog
 
To set the clock frequency on a MCU in Proteus, right click on the MCU in the design and select "Edit Properties" and simply enter the correct frequency in the "Processor Clock Frequency" form slot.

Proteus does not seem to require any oscillator circuitry in the design as long as the entered value is correct.

To set the configuration bits in MikroC for an internal oscillator, simply click on the "Oscillator Selection" menu and select "INTOSC - RA6 as I/O, RA7 as I/O".

BigDog

I want ask another thing. How do I use internal clock and output to SCLK (RC3 - MMC's pin).
Is it related to timer module from PIC18F4520's datasheet ?
 

The PIC18F4520' MASTER SYNCHRONOUS SERIAL PORT (MSSP) module and MikroC SPI library take care of most of the details of implementing a SPI bus.

The following function call setups up the SPI clock line in the MSSP module.
// Initialize SPI1 module
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

The MMC library adds FAT File System functionality to the SD interface with SPI bus.

One other issue I should mention, the MikroC's MMC Library only functions correctly with a SD card which has formatted with FAT16. It will not function with FAT12 or FAT32 according to their documentation.

BigDog
 

The PIC18F4520' MASTER SYNCHRONOUS SERIAL PORT (MSSP) module and MikroC SPI library take care of most of the details of implementing a SPI bus.

The following function call setups up the SPI clock line in the MSSP module.


The MMC library adds FAT File System functionality to the SD interface with SPI bus.

One other issue I should mention, the MikroC's MMC Library only functions correctly with a SD card which has formatted with FAT16. It will not function with FAT12 or FAT32 according to their documentation.

BigDog

Ya, I have formatted my SD card to FAT(default), allocation size (default). Am I right ?
Correct me if I'm wrong.

---------- Post added at 20:36 ---------- Previous post was at 19:54 ----------

And another question is the oscillator connected to CLKIN (PIC18F4520), what's minimum frequency value required ?
 

The question is whether the default FAT formatting was FAT16 or not.

What did you use to preformat the SD, Windows 7, XP PRO, etc?

You may have to use a SD utility to ensure it is FAT16.

BigDog
 

The question is whether the default FAT formatting was FAT16 or not.

What did you use to preformat the SD, Windows 7, XP PRO, etc?

You may have to use a SD utility to ensure it is FAT16.

BigDog


I'm using Windows 7 ultimate.
What's SD utility ?
And for MikroC oscillator selection menu, didnt shows "INTOSC - RA6 as I/O, RA7 as I/O"; only shows "internal oscillator block on port RA6 and RA7".
 

What's SD utility ?

A utility which can format the SD in a specific format. I use several Linux or Cygwin utilities when installing an Embedded OS on SD/MMC cards, due to the fact they must be bootable and formatting is critical.

And for MikroC oscillator selection menu, didnt shows "INTOSC - RA6 as I/O, RA7 as I/O"; only shows "internal oscillator block on port RA6 and RA7".

That should work, it sound like it could be the same setting. Were there any other choices with an internal oscillator?

BigDog
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
I have read the datasheet PIC18f4520 which shown below:
internal block oscillator.JPG

Ok, thank you for utilities introduction.
From above description, it seem internal block oscillator is different from RC oscillator.
Does my understanding correct ?
 

From above description, it seem internal block oscillator is different from RC oscillator.
Does my understanding correct ?

The internal oscillator is a RC oscillator, however you can utilize an external RC oscillator as well in place of a crystal or canned oscillator.

BigDog
 

Ok, thank you for verification.
Erm I have set my MikroC oscillator setting to "internal oscillator block on port RA6 and RA7".
When I run the proteus, I got error simulation which is shown below:
proteus_internal_blck_error.JPG
 

Zip up your current MikroC and Proteus project and upload it.

I attempt to troubleshoot here.

BigDog
 

Zip up your current MikroC and Proteus project and upload it.

I attempt to troubleshoot here.

BigDog


That would be nice.. :)

@Linspire,

You may want to try first a simple code for you to test what is proper clock settings...
 

Zip up your current MikroC and Proteus project and upload it.

I attempt to troubleshoot here.

BigDog

Here's the attachment.
View attachment Testing.zip

You can ignore the void main() function, because I just want to see the output from CLKIN & CLKOUT; which you see in the proteus.


PS. I reupload with two separate folders Mikro C project and Proteus.
Sorry for editting.
 

Attachments

  • testing.zip
    43 KB · Views: 80

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top