CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

program does not rotate

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jacktaylor



Joined: 02 Sep 2017
Posts: 75

View user's profile Send private message Send e-mail

program does not rotate
PostPosted: Thu Mar 14, 2019 1:52 pm     Reply with quote

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;
}
}

Embarassed thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Mar 14, 2019 2:09 pm     Reply with quote

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.
jacktaylor



Joined: 02 Sep 2017
Posts: 75

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 14, 2019 2:25 pm     Reply with quote

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.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 14, 2019 2:43 pm     Reply with quote

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...
jacktaylor



Joined: 02 Sep 2017
Posts: 75

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 14, 2019 3:54 pm     Reply with quote

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.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 14, 2019 4:21 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group