Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MPLAB/C18 Newbie, Simulator Issue

Status
Not open for further replies.

Fred.Amoson

New Member
I am just starting my first MPLAB/C18 project. I've done tons of PIC programming before, but never with MPLAB, never with C18, and never with an 18 series PIC.

I have a new project set up and I am trying to get the basics working before I get out the bread board and really get down to business. The code that I currently have working doesn't seem to transfer to the simulator properly. PORTA and OSCCON do not change to the variables I tell them to. I've attached a screen shot to describe what I mean a little more.

My final target will be a PIC18LF4423 chip.

Any ideas?
 

Attachments

  • ScreenShot001.jpg
    ScreenShot001.jpg
    42.8 KB · Views: 188
Thanks for the suggestion. I tried that adjustment, with the same results.

I was under the impression that you use the i when you are using the ICD2? I am probably wrong on that, I will try to see if I can find out the right answer.

In this scenario I am using the built in "MPLAB SIM" Debugger
 
I ran the simulation on MPLAB (I use a 18F1320 as I'm familiar with it) your simulation seems right. You may have to disable A/D, CMCON that sort of thing with your PIC first.
Code:
#include <p18cxxx.h>
void main(void)
{
    OSCCON = 0x72;
    TRISA = 0x00;
    PORTA = 0xFF;
}
 
You are probably right, I need to look into the A/D, CMCON, etc. more.

I hooked up the real chip to the code, and programmed it. It isn't switching _any_ of the pins high. I assume this is because I haven't set the config or data fuses. To tell it that in in INTRC, etc.

Looking through the datasheet, it seems like I need to set "CONFIG1H". I set CONFIG1H to the proper values by:

#pragma 0x300001 0b00001000

any ideas?
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top