Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 6th February 2008, 04:44 PM   (permalink)
Default MPLAB/C18 Newbie, Simulator Issue

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?
Attached Images
File Type: jpg ScreenShot001.jpg (42.8 KB, 9 views)
Fred.Amoson is offline  
Reply With Quote
Old 6th February 2008, 04:53 PM   (permalink)
Default

I'm new to C18 too, but I recall you use the linker with the i in it. ex PIC18LF4423i.lnk for debug.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 6th February 2008, 05:01 PM   (permalink)
Default

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
Fred.Amoson is offline  
Reply With Quote
Old 6th February 2008, 05:06 PM   (permalink)
Default

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;
}
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 6th February 2008, 07:09 PM   (permalink)
Default

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 by Fred.Amoson; 6th February 2008 at 07:23 PM.
Fred.Amoson is offline  
Reply With Quote
Old 6th February 2008, 07:24 PM   (permalink)
Default

This might help
http://www.voti.nl/pickit2faq/files/boot_main.c
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 6th February 2008, 09:00 PM   (permalink)
Default

Thanks, got the ports blinking. Should be all good from here.
Fred.Amoson is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
RF newbie..electronics newbie jbchrist General Electronics Chat 4 17th May 2007 02:14 PM
Newbie here zenpcs Chit-Chat 2 16th October 2006 06:21 AM
Newbie Question on NPN Transistors arrow General Electronics Chat 27 27th July 2006 03:15 AM
newbie kelvinko Robotics Chat 2 15th August 2003 12:57 PM
newbie newbie newbie Bentov General Electronics Chat 8 1st May 2003 12:15 PM



All times are GMT. The time now is 10:34 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.