Problem with hex file created in MPLAB

takao21203

Joined Apr 28, 2012
3,702
You'd eventually encounter C compilers are a finicky business.

Try to make the old Aztec C working on the 68000.

-The installation is broken you need to replace a small file. For instance you can get something suitable from a SDK CD.

-It is a CLI compiler. So you need a text editor as well. And you need to write small scripts or you have to type a lot each time you compile.

-One small mistake, and the system will need a reboot (which takes a few minutes).

-There is no such thing as PDF files on that machine or comfortable task switching.

-The examples from the original manuals are not written for the Aztec. They don't compile. In order to make them work, you need to add many typecasts. There are also blatant errors you need to find these as well.

After a day or two, if you are eager, you can really make some C sources working. Amazing.

If you went through this without any kind of tutorial, you will not have so much difficulties with modern C compilers. You will have at least some idea what could be wrong. Zoikes! :D

Also you'd have to know where to get the floppy images on the internet. It is all available, just not so easy to find.
 

takao21203

Joined Apr 28, 2012
3,702
Well what is your problem then? Is the chip "dead" or is it something else. It is very seldom that people asking for help do not get a PIC up and running after a while. But PICs can also be hard for a beginner. As they requires very strict attention to details. And reading the datasheet is absolute imperative. Do you also have any other PIC than the 16F877. In your first experiment phase. I would strongly recommend using a PIC with internal oscillator.
Tadao Kikumoto used a coil to drive the uPD444 controller. Works pretty well for PICs. You have to be creative when you work with controllers, and research history, and look how others have done things.

The good thing is you don't need capacitors. 47uH or 100uH are a good starting point.

Be warned- there might be effects you did not ask for, such as spurious frequency deviations. I never experienced them, but that's only one thing which can happen.
 

Attachments

t06afre

Joined May 11, 2009
5,934
Tadao Kikumoto used a coil to drive the uPD444 controller. Works pretty well for PICs. You have to be creative when you work with controllers, and research history, and look how others have done things.

The good thing is you don't need capacitors. 47uH or 100uH are a good starting point.

Be warned- there might be effects you did not ask for, such as spurious frequency deviations. I never experienced them, but that's only one thing which can happen.
Let us for the sake of the OP keep things simple, shall we:rolleyes:
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
Yeah the chip works fine with Jaledit, I did a basic blink on/off with an LED. I also use an arduino but I think C is the most used language in industry so I really wanted to use that. I also have dev c++ and tried the code on that with the pic16f877a.h file copied to the dev includes folder but it didnt recognise it.
 

t06afre

Joined May 11, 2009
5,934
Yeah the chip works fine with Jaledit, I did a basic blink on/off with an LED. I also use an arduino but I think C is the most used language in industry so I really wanted to use that. I also have dev c++ and tried the code on that with the pic16f877a.h file copied to the dev includes folder but it didnt recognise it.
That is fine but let us stay focused on the problems. And clear our minds of any other noise. From what I can see your programmer seems to work. But just to be sure after each successful compile in MPLAB. Load the hex code program and then do a verify(do this every time you reprogram your chip). If this work at least your code is loaded into the chip correct. Do you use breadboard? Then check if both VSS and VDD pair are connected. Breadboards and crystals may something be a problem. So again I would recommend using a chip with internal oscillator. Do you have any other chip you can use
Then you should also post your schematics so we see can how the system is connected up. A common mistake among beginners is to use LEDs without any series resistor as an example
 

takao21203

Joined Apr 28, 2012
3,702
Yeah the chip works fine with Jaledit, I did a basic blink on/off with an LED. I also use an arduino but I think C is the most used language in industry so I really wanted to use that. I also have dev c++ and tried the code on that with the pic16f877a.h file copied to the dev includes folder but it didnt recognise it.
That's kind of naive thinking. The Dev C++ does not have a code generator for PICs as far as I know.

Also you can not use C++ on PICs, as you need some 100 kbytes memory at least (supposed to be RAM).

Breadboards are more a hindrance than a helping, a lot of extra work and connections not that relieable. I do have have breadboards yes, which I sometimes use for small analogue circuits.

Most PICs + LEDs + other digital chips are so cheap you don't really need to reuse them. Plus you may want to keep your circuit maybe.

I have over the years derived a method mounting components directly on the copper side. So they can be removed quickly if need be.

It is not exactly clear to me what is OPs problem now.

Yes the industry almost exclusively uses C for controllers, some amount of BASIC is also used as well PLD languages. Assembler, yes some people use it who claim to be professional. It is on the decaying branch however.

Arduino is mainly used by students and hobbyists, not so much professionally. Nothing speaks agains that, but an Arduino is basically nothing but a controller + USB bootloader + linear voltage regulator.

Bootloader is not really neccessary. And what if you want 20 Arduino? Costs you 500 dollar. I also have one micro Arduino here for reference :)
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
Yeah just did the verification and it come up with "data verified". I have attached the schematic I got out of a book and my breadboard setup. All connections have been checked and are correct and verified with Jaledit (attached)

How do I use the internal oscillator?
 

Attachments

takao21203

Joined Apr 28, 2012
3,702
Yeah just did the verification and it come up with "data verified". I have attached the schematic I got out of a book and my breadboard setup. All connections have been checked and are correct and verified with Jaledit (attached)

How do I use the internal oscillator?
Not all PICs do have one. You need to read through the datasheet. There you will find the answer to such questions. You can get all datasheets from the Microchip website.

By the way if you use a canned oscillator, you leave the other OSC pin open (this one is called OSC2 or CLKOUT).
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
Yeah it doesnt have an internal oscillator, I looked at the datasheet first and it didnt say but another website confirmed it. I tried every combination with osc2 open and gnd'd.

I may have to buy a Microchip pickit if I cant resolve this or resort to using Jaledit and arduino.
 

t06afre

Joined May 11, 2009
5,934
Your 16f877 do not have an internal oscillator. I think the 16f628A have one. What kind oscillator circuit do you use. Then using external osc just use the setup in FIGURE 14-2 in the datasheet.
 

t06afre

Joined May 11, 2009
5,934
Yeah it doesnt have an internal oscillator, I looked at the datasheet first and it didnt say but another website confirmed it. I tried every combination with osc2 open and gnd'd.

I may have to buy a Microchip pickit if I cant resolve this or resort to using Jaledit and arduino.
In this case a PICKIT will not give any other result. But what you can try is to do test setup with RC oscillator. Then make a simple test program. Use PORTC as this is quite simple to use. You just have to set the TRISC register to zero in order to make it a output port
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
I use a 20MHz Epson Crystal oscillator that it connected like the datasheet. Using jaledit I had 2 LEDS flashing on and off so the chip is working and the oscillator. There must be something in the software that I have not set or changed.
 

takao21203

Joined Apr 28, 2012
3,702
The OP asked for a step-by step tuturial. While this is a good idea, it is nearly impossible. There are so many things to observe. Over time you'd automatically do it right from experience, and it would seem obvious. While it is not neccessarily obvious.

Reading the datasheet many times helps.
Observing the PIC memory view, the configuration word as well the disassembly also helps.

PICs are not as foolproof as Arduino, even if they are rather easy to use.

Arduino contains a bootloader already and the ATMega does not need configuration or oscillator setup.

The 16F1503 actually only contains an internal oscillator.

You still have to care of all config bits and set them right, as well you need to set ANSEL to 0.

Play around with the config bits after reading the datasheet.

Polling TIMER0 is just the very basics, next you should use the timer interrupt.

If you can show the PIC memory from your jaledit, and from MPLAB. As well the configuration memory space. Is there any difference?
 

t06afre

Joined May 11, 2009
5,934
I use a 20MHz Epson Crystal oscillator that it connected like the datasheet. Using jaledit I had 2 LEDS flashing on and off so the chip is working and the oscillator. There must be something in the software that I have not set or changed.
I do not know what Jaleedit is. Is it some kind of software simulator? Also do you know for sure that the oscillator IC works. Please set up the system with a simple RC oscillator and then do a test. Remember to change to config oscillator config bits. And also the XTAL setting in the program. Then use PORTC as I said.
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
Yeah I have the book "PIC Microcontrollers 50 projects for the beginners and experts" and it uses jaledit, the attached is the code I used to blink 2 LED's on and off.

Im not sure if the oscillator works but the blink code works so does this mean the oscillator works?

I tried the RC oscillator and I changed the oscillator type to RC in config bits.

To be honest with you I didnt even look at the datasheet because I went straight to the book, the datasheet is over 200 pages and Im not sure what some of the terms mean. What sections of this datasheet is relevant then?

Sometimes datasheets assume that you know what there talking about and are not beginner friendly.
 

takao21203

Joined Apr 28, 2012
3,702
That's why I recommend the 16f59 for beginners or even the smaller 16f54 and 16f57.

Only 50 pages, no pheripherals.

Once you are familiar with the basics, use a more sophisticated chip.

I still use the 16f59- easy to configure. I like this chip for it's simplicity.
 

Attachments

t06afre

Joined May 11, 2009
5,934
Ok so Jaledit is a program language. And then you make a program in Jaledit create a hex file and transfer it to your PIC it work as it should. And have you done that test today? This is kind of important to know.
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
Yeah thats what I did and it works fine. Thats why I think there is something I may or may not have done on the software side of things. Microchip produces the .hex file but it doesnt work.

Can anyone give me the simplest piece of code like turn on a pin of one of the ports? The jaledit code blinks C4 and D3, one then the other.
 

t06afre

Joined May 11, 2009
5,934
That is good news. As it tell us that your PIC work and the same for the oscillator chip. So your problem is either code or configuration word setting.
 
Top