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

PIC12F675 "BLINKY" program

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



Joined: 06 Sep 2006
Posts: 12

View user's profile Send private message

PIC12F675 "BLINKY" program
PostPosted: Wed Sep 06, 2006 9:33 am     Reply with quote

Friends,

I am playing with the PIC12F675 for the first time using CCS version 4.005. I am currently just trying to turn on a LED on GP5 using the following:

---------------------------------------------------------------------------------
#include<12F675.h>
#fuses NOWDT, NOPROTECT, PUT, BROWNOUT, NOCPD, INTRC_IO
#device ADC=10

// Standard libraries needed for basic I/O.
#include <stdio.h>
#include <stdlib.h>


// Tell compiler that clock is 4MHz for use in DELAY routines.
#use DELAY(clock=4000000)

// Configure I/O at beginning of routine.
#use standard_io(A)


void main()
{
set_tris_a( 0x1D );
setup_adc( ADC_CLOCK_INTERNAL );
setup_adc_ports( AN0_ANALOG|AN1_ANALOG|AN3_ANALOG );
setup_timer_0( RTCC_INTERNAL|RTCC_DIV_256 );
setup_timer_1( T1_DISABLED );
setup_comparator( NC_NC_NC_NC );
setup_vref(FALSE);
output_a( 0x20 );
#asm
loop:
nop
goto loop
#endasm
}
-------------------------------------------------------------------------------------

Can anybody see anything wrong with this code. As far as I can tell everything looks like it should be working.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 06, 2006 10:05 am     Reply with quote

Blink implies that it will turn on,...wait some time,... turn off,..wait some time..loop.

Why use loop nop goto loop

Just put a
while(TRUE);

That means while true is equal to true((which is always)) do the next statement. And the next statement is nothing ((a semicolin))

No need for tris as you are using standard_io.. Tris is taken care of by
the output_n statement.

Note that some port A pins can be "open collector" that is it will pull a line
down and can't pull it high. It needs a pull-up resistor.
Ttelmah
Guest







PostPosted: Wed Sep 06, 2006 10:13 am     Reply with quote

First, use the 'code' button to post code, and the tick box 'disable HTML in this post', then it has a chance of being readable. Unfortunately without this, parts of the lines get omitted...
What is shown should work, but all it'll do, is turn the line on. No 'blinking'.
Treitmey, has just posted the other things I was going to say. Smile

Best Wishes
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 06, 2006 10:53 am     Reply with quote

change the pin value to whatever you are using.
Code:
#INCLUDE<12F675>
#USE DELAY(CLOCK=4000000)
#FUSES HS,NOWDT,NOPROTECT
void main()
{
  setup_adc_ports(NO_ANALOGS);
  set_tris_a(0xFF);//setting all pins to input at startup
  while(TRUE){
    output_toggle(PIN_A4);//tris is taken care of by output_n function
    delay_ms(1000);
  }
}
Steve_Kos



Joined: 06 Sep 2006
Posts: 12

View user's profile Send private message

PIC12F675 not so "BLINKY" Program
PostPosted: Wed Sep 06, 2006 1:41 pm     Reply with quote

Thanks guys! Program is working as expected now.

It was "growing pains".
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