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.

Code compiles, but PIC does nothing!

Status
Not open for further replies.

SamanthaL

Junior Member level 2
Joined
Feb 4, 2009
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,474
Hey guys,

Here is my problem. I'm currently working on writing code to link an FPGA to a microcontroller. I was in the process of doing some basic debugging, but it seems like the microcontroller isn't being programmed or it isn't doing anything.

I've tried multiple chips and even another programmer. Each time, it comes up as programming succeeded. My code is attached. Is the problem there? I'm just trying to get it to turn on an LED at this point. Everything else is commented out for now.

Please help!!!!
 

I can not see where you have set up the configuration fuses?
Unless you are setting them up in MPLAB.
In MPLAB, go to 'Configure' and make sure the correct processor is selected and the configuration fuses are correct.
 

    SamanthaL

    Points: 2
    Helpful Answer Positive Rating
btbass,

Thank you for your response. I've spent the past few days looking at the config bits and their definitions. Attached is a screen shot of my configurations as defined in MPLAB. I'm not seeing any problems with them. (But I do admit I am an amateur with this stuff.)

Thank you again for taking the time to help me.
 

SamanthaL,
I'm not an Assembly programmer, but you can simplify your code still further to prove that the programming of the PIC does/does not work.
I think you are setting up Port A and B, but outputting to PortB then moving output data to port D then looping back to clear ports A and B.
Just set up Port B as all outputs, then turn on all of Port B, or just one pin on PortB and do not loop. See if you can get an LED to turn on.
Do you have an MCLR reset circuit that you built yourself or is it on a development board?
If you have a development board, what is it?
Please post your hardware setup with the LEDs- there could be some small problem here :)
I just removed the commented out stuff from your code for the others who read this forum.
Nora
;**************************************************************************
; RESET VECTORS
;**************************************************************************
Count equ 0x00
org 00000h ; Reset vector
goto Start
;**************************************************************************
;Start
;
;Initializes necessary variables and sets necessary pins to
;inputs vs. outputs.
;**************************************************************************
Start
clrf PORTB ; Clear PORTB outputs
clrf TRISB ; Make PORTB pins all outputs
clrf PORTA ; Clear PORTA outputs
clrf TRISA ; Make PORTA pins all outputs

; DEBUGGING CODE
clrf TRISD
movlw b'11111111'
movwf PORTD
;MOVLF b'11111111', PORTD
goto Start[/code]
 

    SamanthaL

    Points: 2
    Helpful Answer Positive Rating
I see you have your oscillator configured to use an external clock source.
Is this what you intend? Or are you using a xtal or resonator?
The Watchdog timer is enabled which will continualy reset the micro unless you periodicaly clear it.
Some Port B lines are set as analog inputs. You need to set them as digital I/O if you are using them.

MPLAB has a very good simulator, MPSIM. If you select that as your debugger, you could step through the code using the Watch winow to see what it's doing.
 

I altered to code to try and turn on the PORTB bits instead. I am still having no luck.

As far as my hardware goes, I am using a 20MHz Oscillator connected to Pins 13 and 14 with two capacitor connecting the oscillator to ground. I also have a 470uF capacitor connecting Vusb to ground (I was also working with a different set of code to try and get USB working.) The power pins are connect appropriately with a 5 V power supply. To connect the LED's, I am using a 1k resistor and the LED. I have no master clear circuitry - is that just connecting the master clear pin to 5V?

I am using a development board to program the chip. The development board is a Qik Start education board design for a pic16, but I'm using a pic18. We know that this board works for programming, but not debugging as we have worked with some C-code and have had no problems uploading the program onto the chip.

I also looked at the Watchdog timer configuration bit. What is the SWDTEN bit? That is the alternate option.

Thanks again guys!
 

For your MCLR pin, you'll either need an external pull up or make sure it is set internally otherwise your code will not run. Unfortunately, I don't know how to do this with your setup as I've only done it externally with hardware.

As btbass says, configure all of your PORTB outputs as digital outputs. Currently you have them configured (in the screenshot you attached) as analog inputs.

Also- make sure LEDS are not wired backwards by using a multimeter on PortB from pin to GND while code is running.
Nora

Added after 12 minutes:

Can you post a link to the MPlab configuration definitions?
Are you using a PIC18F4550?
Do you use MPlab both to compile and to send your code to the PIC?
N
 

dude! yours is an HS oscillator NOT EXTERNAL! if you intend to use USB must select HS with PLL, and select a 5 divider (20Mhz Input) your watchdog must be disable for testingf purposes... also if you are using PORTB, you must disable the Analog inputs in portB...

I would suggest to begin with an easier pic...
 

    SamanthaL

    Points: 2
    Helpful Answer Positive Rating
That is the problem! Thank you very much for your patience and help everyone! I can now return to my original program which is to get the microcontroller to talk to an FPGA. o_O
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top