programming pic

Thread Starter

arashian1

Joined Sep 9, 2016
39
PORTA.F0 = 0;
delay_ms(650);
PORTA.F0 =1;
delay_ms(650);

after excute program above the output pin is off

PORTA.F0 = 1;
delay_ms(650);
PORTA.F0 =0;
delay_ms(650);

after excute program above the output is on but not blinking

the program operated in proteus perfect and programmer show sucsess message after programming

who knows what is wrong with this?

programmer: PICKIT2
 

AlbertHall

Joined Jun 4, 2014
12,347
Which PIC are you using?
Which compiler are you using?
Are you using MPLAB/MPLABX?
Please show all the program before the snippet you give - config, includes, PIC setup, etc.
 

Thread Starter

arashian1

Joined Sep 9, 2016
39
Which PIC are you using?
Which compiler are you using?
Are you using MPLAB/MPLABX?
Please show all the program before the snippet you give - config, includes, PIC setup, etc.
compiler: mikro c pro
programer and software: PICKIT3
microcontroller: PIC16f877a & PIC16f84a
oscilator: 16MHZ
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,787
Is that the whole program? You need a loop to make it blink.
C:
 while(1){
PORTA.F0 = 1;
delay_ms(650);
PORTA.F0 =0;
delay_ms(650);
}
As noted above by @Kjeldgaard (while I was typing) you have to set the port bits to DIGITAL from their default analog configuration. In the '877, that means writing 0x7 to ADCON1.
FWIW, RA4 on both is open drain - it sinks only.
From your description, it sounds like the LED is backwards.

Show your complete code with configuration bit settings, IO initialization and what kind of oscillator you have connected to the chip.

Good luck.
 

Thread Starter

arashian1

Joined Sep 9, 2016
39
Is that the whole program? You need a loop to make it blink.
C:
 while(1){
PORTA.F0 = 1;
delay_ms(650);
PORTA.F0 =0;
delay_ms(650);
}
As noted above by @Kjeldgaard (while I was typing) you have to set the port bits to DIGITAL from their default analog configuration. In the '877, that means writing 0x7 to ADCON1.
FWIW, RA4 on both is open drain - it sinks only.
From your description, it sounds like the LED is backwards.

Show your complete code with configuration bit settings, IO initialization and what kind of oscillator you have connected to the chip.

Good luck.
what about pic1684a? it must set adcon1 too?
 

Attachments

Kjeldgaard

Joined Apr 7, 2016
476
By all PIC16 and PIC18 with ADC, you must initialize portbit to be used as digital I/O.
But be aware that the registers do not have the same name across types.
 

JohnInTX

Joined Jun 26, 2012
4,787
What oscillator are you using? Note that Proteus will simulate without an oscillator but the chip will not work without one. See section 6.1 'Configuration Bits' in the datasheet.

You have no CONFIGURATION bits set - usually done with a #pragma in the C source. The default is an RC oscillator. If you use a crystal or external oscillator, you'll have to change the CONFIG bits.

Don't forget proper power and to pull MCLR/ up as well.
 

AlbertHall

Joined Jun 4, 2014
12,347
but i used this source code for pic16f84a and this model has no ADC
It does look, from your pictures from PICKIT2 (although you say you are using PICKIT3), that the config is set appropriately (for the '877A at least) though it is good practice to include those settings in the source file to ensure they are set correctly and to document them for the future.

Do you have a pull-up resistor on /MCLR?
 

Thread Starter

arashian1

Joined Sep 9, 2016
39
What oscillator are you using? Note that Proteus will simulate without an oscillator but the chip will not work without one. See section 6.1 'Configuration Bits' in the datasheet.

You have no CONFIGURATION bits set - usually done with a #pragma in the C source. The default is an RC oscillator. If you use a crystal or external oscillator, you'll have to change the CONFIG bits.

Don't forget proper power and to pull MCLR/ up as well.
thanks
i did not changed CONFIG bits but after connect MCLR to +5V it worked proper
but for set clock source the register that must be change is CONFIG?
 
Top