Author Topic: Very simple program doesn't work  (Read 2563 times)

0 Members and 1 Guest are viewing this topic.

Offline Tricka90Topic starter

  • Regular Contributor
  • *
  • Posts: 50
Very simple program doesn't work
« on: September 07, 2014, 08:47:47 am »
Hello everybody.

I just bought the PicKit2 44 PIN Demo Board (https://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCMQFjAA&url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fen%2FDeviceDoc%2F41296B.pdf&ei=Sw4LVIbGO4j_OZCngIAG&usg=AFQjCNFmZjaRhRjo1-N-1YA8G9RD0s-pFw&sig2=KBUtjPtvLT_F--s9p8DVgQ&bvm=bv.74649129,d.ZWU) which has the PIC18F45K20 (http://ww1.microchip.com/downloads/en/DeviceDoc/41303G.pdf).

Using sofware MikroC I made this very simple program which should light up the 8 LEDs on the Demo Board:

Code: [Select]
void main(void)
{

TRISD = 0;
PORTD = 1;

while(1)
{
}
}

When I try to program the PIC using PicKit2 it doesn't work. I have another .hex file, made by a friend of mine which does work, so the writing process is correct and the Demo Board works. That means there must be some mistake in the code or the MikroC settings. I tried changing Oscillator settings but it doesn't work.
What do you think about it?
Thank you in advance  :)
 

Offline eurofox

  • Supporter
  • ****
  • Posts: 943
  • Country: be
    • Music
Re: Very simple program doesn't work
« Reply #1 on: September 07, 2014, 09:03:09 am »
Hello everybody.

I just bought the PicKit2 44 PIN Demo Board (https://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCMQFjAA&url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fen%2FDeviceDoc%2F41296B.pdf&ei=Sw4LVIbGO4j_OZCngIAG&usg=AFQjCNFmZjaRhRjo1-N-1YA8G9RD0s-pFw&sig2=KBUtjPtvLT_F--s9p8DVgQ&bvm=bv.74649129,d.ZWU) which has the PIC18F45K20 (http://ww1.microchip.com/downloads/en/DeviceDoc/41303G.pdf).

Using sofware MikroC I made this very simple program which should light up the 8 LEDs on the Demo Board:

Code: [Select]
void main(void)
{

TRISD = 0;
PORTD = 1;

while(1)
{
}
}

When I try to program the PIC using PicKit2 it doesn't work. I have another .hex file, made by a friend of mine which does work, so the writing process is correct and the Demo Board works. That means there must be some mistake in the code or the MikroC settings. I tried changing Oscillator settings but it doesn't work.
What do you think about it?
Thank you in advance  :)

Check your #FUSES  |O
There's No Future In the Past.
eurofox
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2958
  • Country: au
Re: Very simple program doesn't work
« Reply #2 on: September 07, 2014, 09:08:08 am »
Also,

Code: [Select]
PORTD = 1;
will set the LSB of PORTD high and the rest low.
 

Offline Cside

  • Regular Contributor
  • *
  • !
  • Posts: 105
Re: Very simple program doesn't work
« Reply #3 on: September 07, 2014, 09:11:19 am »
Using sofware MikroC I made this very simple program which should light up the 8 LEDs on the Demo Board:
....
PORTD = 1;
.....


try PORTD = 0xFF;
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->