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 CCS Technical Support

Help with 12f683 GP2 and GP1 as output [Solved]

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



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

Help with 12f683 GP2 and GP1 as output [Solved]
PostPosted: Tue Feb 19, 2019 8:01 pm     Reply with quote

I cant figure out how to make GP2 and GP1 as an output.
temtronic



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

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 9:10 pm     Reply with quote

CCS calls them PIN_A2, PIN_A1.....
I'm not too sure why Microchip call them 'GP' when from day one I/O pins have been called by the port name like 'A' or 'B'.

just a qurk ??

Jay
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 9:23 pm     Reply with quote

temtronic wrote:
CCS calls them PIN_A2, PIN_A1.....
I'm not too sure why Microchip call them 'GP' when from day one I/O pins have been called by the port name like 'A' or 'B'.

just a qurk ??

Jay


Sorry, I know the names its not that.

I am using A0 as an input to control a 10k pot as well.

I have an LED on pin 4 A2 and it just flashes.

Code:

void main()
{
   setup_adc(ADC_CLOCK_DIV_8); //must use ADC_CLOCK_DIV_8 or ADC_CLOCK_DIV_16 when clock is set to 4Mhz
   setup_adc_ports(sAN0);
   set_adc_channel(0);
   setup_comparator(NC_NC_NC_NC); //turn off comp

while(TRUE)
{
output_high(PIN_A2);
}
}


Last edited by Rez on Tue Feb 19, 2019 9:27 pm; edited 1 time in total
temtronic



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

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 9:27 pm     Reply with quote

You should post your complete program, but I'm guessing you have the WDT fuse enabled.
Jay
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 9:28 pm     Reply with quote

temtronic wrote:
You should post your complete program, but I'm guessing you have the WDT fuse enabled.
Jay


WDT is disabled
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 9:31 pm     Reply with quote

Code:
#include <12F683.h>
#use delay(clock = 4000000)
#fuses NOMCLR,NOPROTECT,NOWDT,INTRC_IO //,NOIESO,NOCPD,NOFCMEN,NOBROWNOUT

void main()
{
   setup_adc(ADC_CLOCK_DIV_8);
   setup_adc_ports(sAN0);
   set_adc_channel(0);
   setup_comparator(NC_NC_NC_NC); //turn off comp


while(TRUE)
{

output_high(PIN_A2);

}

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 10:09 pm     Reply with quote

Add this line to your setup code in main(). That should fix pin GP2.
Code:
setup_timer_0(T0_INTERNAL);

Timer0 in this PIC defaults to using an external clock on pin GP2.
By adding the above line, it's reconfigured to use the internal clock
and GP2 can now be used as an output pin.
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 10:14 pm     Reply with quote

PCM programmer wrote:
Add this line to your setup code in main(). That should fix pin GP2.
Code:
setup_timer_0(T0_INTERNAL);

Timer0 in this PIC defaults to using an external clock on pin GP2.
By adding the above line, it's reconfigured to use the internal clock
and GP2 can now be used as an output pin.


Thanks for the response, but that still does not work, it just keeps flashing.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 20, 2019 4:13 am     Reply with quote

Do you have a series resistor in your LED circuit ? You need one.
Example:
Code:

pin      470 ohms      LED       
A2  -----/\/\/\/------->|----
                            |
                            |
                          -----  Ground 
                           ---
                            -
 

Use a resistor between 220 and 1K. 470 ohms will work fine.
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Wed Feb 20, 2019 7:16 am     Reply with quote

Classic 'two minds with one thought' here. I just started to post and
saw PCM_programmmer had the same idea.

Thought is that without the resistor, lamp comes on and overloads the
PIC. PIC then stops/crashes, possibly lowering the supply voltage.
It then restarts. Result, flashing LED....

Also, as a 'second thought', make sure the watchdog actually is disabled. If
(for instance) the programmer was not set to update the fuses, you could
have the watchdog 'off' in the code, but it still 'on' in the chip.
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Wed Feb 20, 2019 12:48 pm     Reply with quote

Yes there is a resistor. I tried using port A1 (GP1) and it does the same thing.
I am using a PICKit 2 programmer.
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Wed Feb 20, 2019 1:06 pm     Reply with quote

LMAO, I am so dumb. I just know realized I was using a flashing LED I have know idea how it got into my regular batch of LED's.
Rez



Joined: 10 Feb 2019
Posts: 26

View user's profile Send private message

PostPosted: Wed Feb 20, 2019 1:13 pm     Reply with quote

Everything is working fine now, I didb't have to add anything to the code, It was just the flashing LED. WOW!
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Wed Feb 20, 2019 2:45 pm     Reply with quote

No wonder it flashed!....

That's a real 'silly'. Very Happy
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