PDA

View Full Version : Help Getting Started



doggitz
- 22nd August 2009, 22:53
I'm right out of the starting gate with PIC programming but did BASIC on punch cards in college 35 years ago. Frustrated, and would appreciate some help.

Just bought the LABX-1 Board, PicBasic Pro and Melabs U2
Using a 16F877a
Here is my program

clear
adcon1 = 7
mainloop:
high portd.0
Pause 500
low portd.0
pause 500
goto mainloop
end

The compiler says that it is compiled successfully and then it loads via the USB ME LABS PROGRAMMER into the X-1 without error, but nothing happens when I load it into the board/chip. When I look at the memory tab of the programmer, I see that a hex file was created. Yes, I have checked to be sure that the polarity of the led bar graph and the JP2 jumper are correct. I have even tried it using low portd.0 just for giggles, and that doesn't work either. I've tested the programmer and the board/chip using the board test program that was included with the board (in hex) and the board runs fine, making the leds blink, lcd display, etc.

I've read and reread the book but can't find what I'm doing wrong. Sorry to trouble you all with such a basic question, but my head hurts from banging it in the wall.
Thanks

mackrackit
- 22nd August 2009, 23:15
What are you using for an oscillator and how are the configs set?

doggitz
- 22nd August 2009, 23:38
Thanks for your quick reply!

I am using the 4 MHz crystal that came mounted on the board
The configs for the programmer are:
Osc XT
Watchdog Enabled
Power-up Timer Enabled
Brown-out Enabled
Low Voltage Pgm disabled
flash pgm write All
Code NOT protected
Data EEPROM Not protected

I took these setting from the board test program that works

Thanks
Fred

mackrackit
- 23rd August 2009, 07:50
Maybe try HS OSC.
But if it worked the way you have it on the sample, it is just a guess.

Archangel
- 23rd August 2009, 23:18
Add these to you code:
DEFINE OSC 4 ' Tells your PIC how fast it is running
ADCON0 = 0 ' Disable A/D
CCP1CON = 0 "Disable Comparators

Power on.MCLR,BOD, . . . reset . . . Defaults to TRISD = %11111111
TrisE = %00001111 FYI check Datasheet 3.5 RE: MSP if TrisE.4 is set, As a beginner, if I were you, I would park that HP Chevelle in the garage and practice in the Toyota. A 16F628A, 16F648A, or !6f690 with PICKIT2 and Demo board, Get your feet wet with those, then go back to the 877. Just my opinion.

doggitz
- 24th August 2009, 00:11
Thanks for the advice

I did try changing the oscillator type to HS - no luck

I will try the other suggestions. I read a fair amount before investing and was under the impression that the 16F877a was a reasonable place to start. Maybe not!

Thanks

Fred

mackrackit
- 24th August 2009, 00:43
I still think the 877A is a good starter chip. It can do enough things untill you need LONGS or something like that.

Seems like there is some problem with the programs that set the fuses for you over riding the code. At least over the years it seems like this has come up before.

On the test board, is the OSC a resonator or does it have capacitors added?

Port D is non analog so that should not be the problem. MCLR has to be tied high on this one. High and Low make the pin an output so TRIS should not be it either.

I still think it is in the programers software.

doggitz
- 25th August 2009, 03:52
I think there is something wrong in the programmer. Nothing that I write in PBPRO seems to work. In fact, the ONLY thing I have gotten to run is the .hex X-1 board test file that came with the development board. The interesting thing is that this file is loaded directly into the programmer and never passes through PBPRO.

I looked at the configurations of the compiler. PBPRO came with Mecanique microcode and that is the IDE I'm using. It also came with MPLAB so I played with it a bit. According to the info that came with the compiler, for the 16F series, the IDE automatically uses MPASMWIN - so I looked at that. It is creating a hex file, so I took the hex file and passed it to the melabs USB programmer and then programmed the chip - I even used the manual clear on the programmer and then checked the memory in the chip after programming to be sure that the same hex file was present in the chip as that created by MPASM. I also switched off MPASM and opted to use the PM assembler provided - no luck. I even wrote the a simple led on/off program in assembly using the ASM...ENDASM commands in PBPRO and that didn't work. The bottom line is that nothing I do in PBPRO works. The problem is likely so fundamental that "we" are all overlooking it. Yes, the board is plugged in and I have measured the Vdd (4.99V).

Thanks

Fred

Archangel
- 25th August 2009, 04:56
Hi Fred,
Make sure which "Compile" you are using ICD Compile does not work unless you are using the ICD. PBP generates an INTEL Hex file and that is what your programmer needs to find, and load onto the chip. It generates asm and mac and some others too. All with the filename you chose.
My comments regarding the 16f628 . . . is due to their not having adcon ansel . . .

According to the info that came with the compiler, for the 16F series, the IDE automatically uses MPASMWIN PBP usually defaults to it's own assembler in MCS to use mpasm you have to change the setting . . . file, view, compiler options, assembler tab, check box use mpasm

doggitz
- 25th August 2009, 14:34
SUCCESS !!!

Thanks everyone for your help. I really appreciate your insights!
I did use the MPASM switch and it worked. The other thing that I did was send a "manual" erase from the programmer screen and then checked to be sure that the chip was blank before loading my program. I had lights flashing all night!! Now on to my project -

Thanks AGAIN
Fred

Archangel
- 25th August 2009, 21:30
<h1> Congratulations !</h1> Feels pretty good huh?