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

12f508, INTRC problem

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



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

12f508, INTRC problem
PostPosted: Fri Sep 10, 2010 7:08 pm     Reply with quote

I'm using the 12F508 to send serial data, but I'm having a strange problem. The chip only functions when I connect a resistor from GP5 to V+, and depending on the ohms of the resistor, it changes my clock frequency. I need to use all 6 I/O pins of this chip so I'm trying to figure out why it only functions when I connect that resistor. It shouldn't require any external components to work. If there's no resistor, the chip does absolutely nothing. As soon as I connect the resistor, it functions just fine.

Compiler 4.033

Code:
#include "12f508.h"
#use delay(clock=4000000)
#Fuses LP,INTRC,NOWDT,NOPROTECT,NOMCLR
#use RS232(BAUD=9600,FORCE_SW,XMIT=pin_B4)

void main()
{
   while(1)
   {
      if(input(pin_B2))
      {
         output_high(pin_B0);
         putc(123);
      }
      else
      {
         output_low(pin_B0);
      }
   }
}


Any ideas?
_________________
Vinnie Ryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 10, 2010 8:23 pm     Reply with quote

Quote:
#Fuses LP,INTRC,NOWDT,NOPROTECT,NOMCLR

You have two oscillator fuses. Use only one.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Fri Sep 10, 2010 9:29 pm     Reply with quote

oops that was a last minute mistake, forget the LP it's not supposed to be there, and it wasn't there when I did my testing.
_________________
Vinnie Ryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 10, 2010 11:54 pm     Reply with quote

Quote:

The chip only functions when I connect a resistor from GP5 to V+, and
depending on the ohms of the resistor, it changes my clock frequency.

The thing that most closely fits your description would be that you don't
have the PIC's Vdd pin connected directly to power. It's just floating.
Therefore, the pullup resistor on the GP5 i/o pin is supplying current
through the upper protection diode on that pin. As you change the
resistor value, you vary the (slight) amount of current, and you change
the operating voltage of the PIC, which then changes the frequency
of the internal oscillator.

Secondary possibilities are that the PIC is not really being programmed in
INTRC mode, and it's actually running in external RC oscillator mode.
This could possibly explain the symptoms. A final possibility is that you
clobbered the OSCCAL value at the end of ROM, and this is causing
strange problems.

My bet is on the first one. Vdd is floating.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Sun Sep 12, 2010 9:30 pm     Reply with quote

PCM,

Here's my schematic.



I made sure my connections are correct, VDD is receiving 3.0V, all connections have been tested. In the schematic above, all (open) pins have been programmed as RS232 TX, but no matter which pin I use as TX, the problem persists. As soon as I connect a resistor from B5 to V+, the chip begins working properly, but again - depending on the resistor value, the oscillator changes frequency.

As for your other suggestions, I'm not quite sure how to check if the pic is being programmed in INTRC mode. I'm using the ICD-U64 programmer.

To be 100% correct, this is the program I'm running on the PIC:

Code:

#include "12f508.h"
#Fuses INTRC,NOWDT,NOPROTECT,NOMCLR
#use delay(clock=4000000)
#use RS232(BAUD=9600,FORCE_SW,XMIT=pin_BX) //all pins have been tried

void main()
{
   while(1)
   {
      //Setup_Timer_0(0); //tried with and without
      if(input(pin_B2))
      {
         output_high(pin_B0); //LED
         putc(123);
      }
      else
      {
         output_low(pin_B0); //LED
      }
   }
}


I'm using the 8 pin package, so I only have 6 I/O pins, and in the data sheet the pins are listed as GP0, GP1, GP2.. ~ GP5. In the compiler, they're listed as B0-B5.
_________________
Vinnie Ryan
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Sun Sep 12, 2010 10:25 pm     Reply with quote

I did a little more testing, I tried the code above using LP, XT, RC, INTRC, and even not declaring an OSC fuse, and no matter what config I use, I have the exact same result. 10K resistor from B5 to 3V+ it functions, no resistor, no function.

Is there some way to manually set the osc fuse? It seems it's not being set so it's defaulting to RC, in the header file for the 12f508 it lists the osc calibration address as 05.

Thanks!
_________________
Vinnie Ryan
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Mon Sep 13, 2010 1:58 am     Reply with quote

Seriously, get rid of R1, and put a series resistor in line with the LED. You may well be getting a version of the RMW problem, overloading the B0 output. As such this could be resulting on almost anything happening, so fix this first.

Best Wishes
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Mon Sep 13, 2010 2:46 am     Reply with quote

I removed R1 and tried it with a series resistor of 1K, same problem. Then I tried removing the LED and resistor and left B0 floating, same. Then I tried re-programming it to not even output on the B0 pin, but that didn't change anything either.
_________________
Vinnie Ryan
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Mon Sep 13, 2010 3:03 pm     Reply with quote

After a firmware and compiler update, the problem seems to be corrected. Thank you all for the help!
_________________
Vinnie Ryan
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