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] Problems with 12F508 and 12F509 acting weird

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



Joined: 01 Sep 2009
Posts: 8
Location: England

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

[help] Problems with 12F508 and 12F509 acting weird
PostPosted: Mon Aug 09, 2010 4:07 am     Reply with quote

hi guys,

I've been debugging this again and again and it's odd cause it acts differently each time...

I'm using PCWH to program and Mach-x through CCSLOAD to flash the chips.
Mach-x is running at 4.75V.
I'm testing this just applying 5volts to the pins and testing back with a LED.
Code:

#include <12F509.h>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR       
#use delay(clock=4000000)

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

// Inputs
#define in5      !INPUT(PIN_B5)
#define in4      !INPUT(PIN_B4)
#define in3      !INPUT(PIN_B3)
//==================================
void main()
{
   
   set_tris_b (0x38);   // PINs_B0-2 output  // PINs_B3-5 input
   set_options(0xC0);   // Allow use of GP2 for i/o
   
   // All off
   output_low(PIN_B0); 
   output_low(PIN_B1);
   output_low(PIN_B2);

   while(TRUE)
   {
            /*
            output_high(PIN_B0);
            output_high(PIN_B1);
            output_high(PIN_B2);
            delay_ms(500);
            output_low(PIN_B0);
            output_low(PIN_B1);
            output_low(PIN_B2);
            delay_ms(500);*/
   
            if(in5) output_high(PIN_B0);
            else output_low(PIN_B0); 
           
            if(in4) output_high(PIN_B1);
            else output_low(PIN_B1);
           
            if(in3) output_high(PIN_B2);
            else output_low(PIN_B2);
   }
}

With the above code the chip turns B0 and B2 together if I apply voltage to in5 and does nothing on the other inputs.
If I swap the code to the blinking code that is commented it does nothing at all.

We have running here a much much complex 18F8722 with no problems. But this little simple chip is been a HUGE headache.

Any suggestions is greatly appreciate.
Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 11:13 am     Reply with quote

Quote:

#include <12F509.h>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
#use delay(clock=4000000)

// Inputs
#define in5 !INPUT(PIN_B5)
#define in4 !INPUT(PIN_B4)
#define in3 !INPUT(PIN_B3)

Look at the pin features in the 12F509 data sheet, and at the oscillator
options. Look at the possible #fuse settings for the internal oscillator
in the 12F509.h file. Then you will see what is wrong.
Rijiru



Joined: 07 Sep 2010
Posts: 3

View user's profile Send private message

PostPosted: Tue Sep 07, 2010 6:38 pm     Reply with quote

Hi, I've a trouble with PIC 12F509, when I program the chip, GP2(PIN_B2) no works.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 07, 2010 7:57 pm     Reply with quote

Use the forum's search page to search for this:
Quote:
12F509 GP2

Set it to: Search for all terms (This is essential).

Then you find threads like this:
http://www.ccsinfo.com/forum/viewtopic.php?t=33336&start=3

Here's the search page:
http://www.ccsinfo.com/forum/search.php
Rijiru



Joined: 07 Sep 2010
Posts: 3

View user's profile Send private message

PostPosted: Wed Sep 08, 2010 2:32 pm     Reply with quote

Hi, PCM programmer thank you for your help, GP2 works, with a macro added.


Greetings
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