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

Help with PIC12F509

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








Help with PIC12F509
PostPosted: Thu Jun 04, 2009 9:28 am     Reply with quote

Code:

#include<12f509.h>

#fuses INTRC, NOWDT, MCLR

#use delay(clock=4MHz)
#use fast_io(b)

// * GPIO PORT DEFINITIONS *****************************************************
#define ON            PIN_B1 // (Input, discrete)
#define OFF           PIN_B2 // (Input, discrete)
#define PUMP          PIN_B4 // (Output)
// *****************************************************************************

#define set_options(value)   {#ASM         \
                              MOVLW  value \
                              OPTION       \
                              #ENDASM}

void main(void) {
   
   set_tris_b(0b00001111);
   set_options(0xC0);
   output_high(PUMP);
   output_high(PIN_B5);
}


I can't seem to get this simple code to do anything. I have a relay on B4 and a relay on B5 both buffered with an NPN transistor. Can't get either outputs to come on and I've checked it with a scope. It remains low. I've also had a while(TRUE) loop around the output functions but removed it in a feeble attempt to make the PIC do something. I've tried 3 PICs now so I am sure the devices are good and they program/verify fine.

I'm using CCS version 4.050
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 11:21 am     Reply with quote

1. Strip your program down so it's more simple, as shown below.
2. Make sure that you have a pull-up resistor on the MCLR pin.
Use 10K for the ICD2, or 47K for the ICD-U40.
3. Remove all external circuits that might be interfering with the pin i/o.
Only the Vdd, Vss and MCLR pins should have external connections for
this test.
Code:
#include<12F509.h>
#fuses INTRC, NOWDT, MCLR
#use delay(clock=4000000)

#define PUMP   PIN_B4

//============================
void main(void)
{
output_high(PUMP);
output_high(PIN_B5);

while(1);  // Prevent PIC from going to sleep
}
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 12:03 pm     Reply with quote

What PCM stated, also, take a look at the file: EX_8PIN.C in your \PICC\EXAMPLES directory.
_________________
A HW Engineer 'trying' to do SW !!! Run!!!
Guest








Problem fixed (sort of)
PostPosted: Fri Jun 05, 2009 7:49 am     Reply with quote

Thanks for the pointers guys but it turns out that it would never work regardless of what I do. The problem appears to be in the ccsloader program that I just downloaded from CCS. It's broken. I loaded the exact same code with the old ICD-U40 program and it works fine. I like the look and layout of the new ccsloader program but all that is irrelevant if it can't properly program the chip. Also there is another irritating bug in it that when you select the chip sometimes it will still say there is no target device defined.
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