If you scroll down and look at the address 0x7F9 you'll see more data which is the actual program location. C compilers sometimes create strange assembly code.
You should also have pullups on the unused pins or program them as outputs
i have set mine to:
Oscillator = HS
Watchdog timer = off
Power-up timer = on
Brownout detect = off
Low voltage program = disable
Flash program write = write protection off
Data EE code protect = off
Code protect = off
HEX: 3F32
As pointed out, 4 MHz crytals use 'XT' for oscillator configuration instead of 'HS', or the oscillator might not start (from my experience). Added configuration labels for Hi-Tech PICC with your setup.
I did try the XT, so im not sure what i was doing wrong, although this time i did use a pull-up resistor and the Masterclear grounded while the chip was inserted.
Anyway thanks for all the help guys this is a great community, i dont think ill try much more before my ZIF socket comes- i think the IC is starting to metal fatigue.
Thanks, superb!
edit:
btw what does
#include<htc.h>
do? that might of been whats missing.
ok after abit of testing it turns out the error was the configuration bits, as i dident know how to set them in the code i was setting them via MPLAB and in WINPIC800 under the configuration tab - but apparently that dident work and they had to be coded in, strangely
This header makes your code more portable. You don't need to include <pic.h>, because the header file htc.h determines which compiler is running and include the specific header file (pic.h, pic18.h, etc.)
As you've realized, the configuration was the issue. If you use config labels as I did in the above program, your code will be more readable by others.
im sorry, no one mentioned how to set the bits in the code, untill pommie and eng1, plus you could configure manually the bits in MPLAB and in WINPIC800 - which i was doing correctly - and so assumed than if i changed them in the window they would change in the program - or whats the point in the ability to change them in the window?
Anyway thanks guys, currently wiring up an LCD to test on this
Glad to hear it's working. It's a good moment when that first LED flashes.
I agree with Eng1 in regard to the use of labels in the config. Just copy his config line. I just copied the hex from MPLAB's config window as I was being a bit lazy.
Good luck with the LCD, I assume it's a character LCD and not a graphic one. Keep us posted.
I cant say how relived i was, never saw a more beautiful LED blink in my life lol
Yes its just a 16x2 character LCD [for now ], just doing the code for it thanks
I was about to look this up, but seeing as im posting here anyway, if i want to set a specific port as an 1 or 0 without changing any of the other ports within a register output, how is it done
example, i want to change B3 from 0 to 1 say without redefining the entire register for B,
can you do it like arrays?
PORTB[3] = 1?
because that's not working for me :S
I was about to look this up, but seeing as im posting here anyway, if i want to set a specific port as an 1 or 0 without changing any of the other ports within a register output, how is it done
example, i want to change B3 from 0 to 1 say without redefining the entire register for B,
can you do it like arrays?
PORTB[3] = 1?
because that's not working for me :S
You should be able to figure it out from my example above Be aware that the sintax for clearing/setting bits of a register or port is compiler specific.
You mean the PIC won't draw extra current when all the input pins are floating at around 1/2 Vdd? Always thought that it would. Maybe I'll experiment with this later.
You mean the PIC won't draw extra current when all the input pins are floating at around 1/2 Vdd? Always thought that it would. Maybe I'll experiment with this later.
I just tried it out on portB of a 18F4620. I set portB to input mode, connected all 8 pins to a pot wired to vary the voltage between 0 & 5V. I first programmed the PIC to just loop doing nothing while using the internal osc at 1Mhz. Idle current was 1.5ma when the pot was at 0 or 5V. When the pot outputted a voltage of around 2V, current peaked at around 3.5ma. With the PIC programmed to just poll portB (Read portB into W and loop) the current would peak at around 4ma. I also tried this at 32Mhz using the PLL. The current increase was about double (19ma idle vs 23ma = 4ma extra for "floating" inputs). So only a 2-4ma punishment for letting all 8 pins on a port float. Nowhere near what you'd see with a standard CMOS gate.
Ok, you've convinced me.
I'm pleased to see you put "floating" in quotes, because (as you're obviously aware) the pins weren't 'floating' at all, but being artificially forced to a non-logic state.