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.
this one is blinking properly.. I edited your circuit as well

Hi, the file's corrupted.
Can you reupload again ?

P/S: Why you working on port C and do blinking code ?
I want to test out the output from the oscillator CLKOUT and CLKIN pin 13 & 14.
 
Last edited:

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:
View attachment 61131

pls use this setting and try
1001 = Internal oscillator block, CLKO function on RA6; port function on RA7
 

Attached is the fixed project with FOSC/4 on CLKOUT PIN with a scope attached to the CLKOUT PIN showing a 2MHz signal.

You forgot to initialize the OSCCON register for an INTOSC of 8MHz.

BigDog
 

Attachments

  • Linspire.zip
    51.9 KB · Views: 137

You forgot to initialize the OSCCON register for an INTOSC of 8MHz.

Thank you,but how do you know what's this "OSCCON" term intialized in MikroC and value set ?
 

Reference the PIC18F4520 Datasheet, pg. 29 & 30, Section 2.7.1 OSCILLATOR CONTROL REGISTER and the following OSCCON Configuration Table.

OSCCON is the Internal Oscillator Control Register and must be configured correctly for the Internal Oscillator to run at a desired frequency.

When you failed to configure this register, the Internal Oscillator was running at a default frequency of 1MHz.

There is also a preference setting in the PIC simulation block which must be set to allow the FOSC/4 clock to be output on the CLKOUT pin.

BigDog
 
Reference the PIC18F4520 Datasheet, pg. 29 & 30, Section 2.7.1 OSCILLATOR CONTROL REGISTER and the following OSCCON Configuration Table.

OSCCON is the Internal Oscillator Control Register and must be configured correctly for the Internal Oscillator to run at a desired frequency.

When you failed to configure this register, the Internal Oscillator was running at a default frequency of 1MHz.

There is also a preference setting in the PIC simulation block which must be set to allow the FOSC/4 clock to be output on the CLKOUT pin.

BigDog

Yap, I'm understandstand thank you for explainantion.
Another question, How'd I know the "term" MikroC they provided or defined them in order to match the PIC datasheet register term defined like

In PIC18F4520 datasheet: "OSCCON"
In MikroC Pro : "OSCCON"

Another simple example:
In PIC18F4520 datasheet: TRISB
In MikroC Pro : TRISB1_BIT or TRISB2_BIT ..etc

Hope my question does not borther you.
 

According to the MikroC documentation:

All PIC SFR registers and their bits are implicitly declared as global variables. These identifiers have an external linkage, and are visible in the entire project. When creating a project, the mikroC PRO for PIC will include an appropriate (*.c) file from defs folder, containing declarations of available SFR registers and constants.

For a complete set of predefined globals and constants, look for “Defs” in the mikroC PRO for PIC installation folder, or probe the Code Assistant for specific letters (Ctrl+Space in the Code Editor).

Reference the P18F4520.c file in the "Defs" directory, the directory contains files similar to the header files used by normal C compilers.

....
....
sfr unsigned short volatile SSPBUF absolute 0x0FC9;
sfr unsigned short volatile T2CON absolute 0x0FCA;
sfr unsigned short volatile PR2 absolute 0x0FCB;
sfr unsigned short volatile TMR2 absolute 0x0FCC;
sfr unsigned short volatile T1CON absolute 0x0FCD;
sfr unsigned short volatile TMR1L absolute 0x0FCE;
sfr unsigned short volatile TMR1H absolute 0x0FCF;
sfr unsigned short volatile RCON absolute 0x0FD0;
sfr unsigned short WDTCON absolute 0x0FD1;
sfr unsigned short volatile HLVDCON absolute 0x0FD2;
sfr unsigned short volatile LVDCON absolute 0x0FD2;
sfr unsigned short volatile OSCCON absolute 0x0FD3;
sfr unsigned short volatile T0CON absolute 0x0FD5;
sfr unsigned short volatile TMR0L absolute 0x0FD6;
sfr unsigned short volatile TMR0H absolute 0x0FD7;
sfr unsigned short volatile STATUS absolute 0x0FD8;
.....
.....

Most of the Special Function Register (SFR) names in the devices datasheet are available in the MikroC compiler.

BigDog
 
According to the MikroC documentation:



Reference the P18F4520.c file in the "Defs" directory, the directory contains files similar to the header files used by normal C compilers.



Most of the Special Function Register (SFR) names in the devices datasheet are available in the MikroC compiler.

BigDog

Nice explaination. Thank you BigDog.
Now I having LCD hardware display problem, when I connect voltage supply, LCD display only shows two rows of black dots with several columns instead of first row black dots.
 

Nice explaination. Thank you BigDog.

No Problem.
I'm more than happy to try and answer any of your question.


Now I having LCD hardware display problem, when I connect voltage supply, LCD display only shows two rows of black dots with several columns instead of first row black dots.

Sounds like a LCD initialization issue or possibly a contrast setting issue.

Are you using the MikroC LCD Library for your LCD driver?

Can you post your code and a schematic for the design?

BigDog
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Sounds like a LCD initialization issue or possibly a contrast setting issue.

Are you using the MikroC LCD Library for your LCD driver?

Can you post your code and a schematic for the design?

BigDog

Last time I post the thread about LCD & PIC18F4520 & MikroC, it works.
But somehow now, when I connect simple connection just to test the hardware LCD is working or not but it's not working now.
Here's the attachment pic :

060920112312.jpg060920112315.jpg060920112324.jpg

What I know is, when we all just connect GND & Vee to GND ; VCC & E to Vcc(5V).
The LCD 16x2 will display one first row with 16 dark square box.
I think I spoiled the LCD.
 

What I know is, when we all just connect GND & Vee to GND ; VCC & E to Vcc(5V).
The LCD 16x2 will display one first row with 16 dark square box.
I think I spoiled the LCD.

I would use a 10KΩ pot on the contrast pin rather than tie it to ground. The Vee contrast pin attaches to the center arm of the pot with the other pot pins attached to GND and Vcc respectfully.

In a pinch you could use two 5KΩ resistors as a voltage divider with the Vee contrast pin attached between the two.

BigDog
 

Last time I post the thread about LCD & PIC18F4520 & MikroC, it works.
But somehow now, when I connect simple connection just to test the hardware LCD is working or not but it's not working now.
Here's the attachment pic :

View attachment 61179View attachment 61180View attachment 61181

What I know is, when we all just connect GND & Vee to GND ; VCC & E to Vcc(5V).
The LCD 16x2 will display one first row with 16 dark square box.
I think I spoiled the LCD.

you have to connect the E pin and RS to the microcontroller and R/w to ground.after writing command/data to the lcd data bus a pulse should be given on the E pin to transfer the command or data to lcd.if one row of lcd is with dark squares when u give the supply then its working, but the commands are not properly recieved.have a look at this pic https://www.extremeelectronics.co.in/pictutorials/images/pic_lcd_interface_schematic.gif
 

Hi guys,
Thank you for your several opinions here.
However, I have two LCD has this kind of conditions, yet I dont have spare right now.
I test another one tomorrow.

I will update you guys then.
 

Guys,
I have burn out my PIC18F4520 due to static charges.
By the way, I want confirm the mikroC SD/MMC library only supported for the PIC18 series not PIC16F8870 due to RAM memory insufficient.
Am I correct ?


Regards,
Linspire
 

By the way, I want confirm the mikroC SD/MMC library only supported for the PIC18 series not PIC16F8870 due to RAM memory insufficient.
Am I correct ?

Reference the MikroC Pro User Manual, pg 368, Section MULTI MEDIA CARD LIBRARY:

MikroC Pro User Manual

Notes:
- Library works with PIC18 family only;
- The library uses the SPI module for communication. User must initialize
SPI module before using the SPI Graphic Lcd Library.
- For MCUs with two SPI modules it is possible to initialize both of them and
then switch by using the SPI_Set_Active() routine.
- Routines for file handling can be used only with FAT16 file system.
- Library functions create and read files from the root directory only;
- Library functions populate both FAT1 and FAT2 tables when writing to files,
but the file data is being read from the FAT1 table only; i.e. there is no
recovery if FAT1 table is corrupted.

Yes, you are correct.

BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top