View previous topic :: View next topic |
Author |
Message |
jacktaylor
Joined: 02 Sep 2017 Posts: 75
|
program does not rotate |
Posted: Thu Mar 14, 2019 1:52 pm |
|
|
Hello friends, I'm having trouble with a code from an RF receiver.
Using the same settings for the PIC12F675 microcontroller of the original code, I inserted in the while the commands for output Led1.
I made this simple code to invert the state of an output, but the output Led1 does not oscillate to one and zero. Can someone help me find the error in this code?
Code: |
#include <12F675.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, NOCPD, NOPROTECT, NOMCLR, NOPUT, BROWNOUT
#byte gpio = 0x05
#byte tris = 0x85
//!#bit rfin = 0x05.3 //pino 4 recepcao
//!#bit c1 = 0x05.0 //pino 7
//!#bit c2 = 0x05.1 //pino 6
//!#bit c3 = 0x05.2 //pino 5
//!#bit c4 = 0x05.4 //pino 3
//!#bit c5 = 0x05.5 //pino 2
#define Led1 PIN_A0
//!#define Led2 GPIO.F0.
//!#define Led3 GPIO.F1
//!#define Led4 GPIO.F2
//!#define Led5 GPIO.F4
void main() {
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
tris=0b001000;
//=============================================
// Loop Principal
//=============================================
while(true){
output_high(Led1);// c1 =1;
delay_ms(5);
output_low(Led1);// c1=0;
}
} |
thank you |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19367
|
|
Posted: Thu Mar 14, 2019 2:09 pm |
|
|
You'd probably never see it go low.
It goes high for 5mSec, but then low for perhaps 4uSec.
Even 5mSec is faster than you would probably see....
(use the code buttons...).
Code: |
while(true){
output_high(Led1);// c1 =1;
delay_ms(50); //You won't see 5mSec
output_low(Led1);// c1=0;
delay_ms(50);
}
|
Should flash at 10Hz, which could be seen. |
|
![](templates/subSilver/images/spacer.gif) |
jacktaylor
Joined: 02 Sep 2017 Posts: 75
|
|
Posted: Thu Mar 14, 2019 2:25 pm |
|
|
Thanks for the reply, Ttelmah.
The initial value was 500ms, but I had gone down to 5ms to do the test in MPLAB, in the MPLAB the output oscillates.
I have placed 50ms, value proposed by you, up to 500ms, even though the Led1 output does not blink. Do not debug in the Proteus nor blink in the Proteus, nor in the assembly practice. I already checked all the fuses.
I still have the same problem. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Thu Mar 14, 2019 2:43 pm |
|
|
OK, silly test... check the LED and resistor. CONFIRM LED polarity and that it really does work. Stranger things have happened.....
Also disable any other peripherals on the pin... |
|
![](templates/subSilver/images/spacer.gif) |
jacktaylor
Joined: 02 Sep 2017 Posts: 75
|
|
Posted: Thu Mar 14, 2019 3:54 pm |
|
|
Very strange, nothing works.
I am now testing only on Proteus.
Does the program have no correct errors?
As for the leds the microcontroller output is connected to the anode of the led and the cathode goes a resistor of 220ohmn and the output of the resistor is connected to ground.
Now the transmitter program works normally with the same PIC and the same settings. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Thu Mar 14, 2019 4:21 pm |
|
|
Get rid of Proteus ! See sticky PIC101. Proteus is known to be full of bugs,errors and faulty DRCs....bottom line.. don't trust it ! Think Blue Screen Of Death !!
From a hardware aspect 220 is a tad low, I usually use 500r for 5 volt PICs, 470 is commonly used. 680-1K should be fine, try to limit current to 10ma.
Also try another I/O pin, actually all that can be outputs. Perhaps the PIC is partially damaged. Try another PIC ?
Jay |
|
![](templates/subSilver/images/spacer.gif) |
|