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

Problem with 10F200

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



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

Problem with 10F200
PostPosted: Sun Apr 21, 2013 6:46 am     Reply with quote

Hi, everyone! I have a problem with PIC10F200. The controller doesn`t output signals on it`s pins. Here is my code:
Code:

#include <10F200.h>
#FUSES NOWDT
#use delay(clock=4M)

void main()
{
   output_drive(PIN_B2);
   while(1)
   {
      output_high(PIN_B2);
      delay_ms(1000);
      output_low(PIN_B2);
      delay_ms(1000);
   }
}

And when I run this I have 1.6V on pin B2, but the Vcc is 4.4V(from PIC Kit 3)
Can you tell me what I`m doing wrong??
Thanks!
dyeatman



Joined: 06 Sep 2003
Posts: 1935
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 6:58 am     Reply with quote

Look at the order of precedence on datasheet page 25 and you will see the pin is
used for multiple functions. I/O is the lowest order with TOCK1 and FOSC
being higher. This means those options must be disabled before the pin will
work for digital IO
_________________
Google and Forum Search are some of your best tools!!!!
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 10:15 am     Reply with quote

OK! I far as I understood I have to set OPTION_REG`s bit 5 to 1 and OSCCAL register`s bit 0 to 0.
In Special Function Registers I set OPTION_REG to 0xFF and OSCCAL to FE and again I have 1.6V on pin B2.
How do I have to set this values? Am I doing it wrong?
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 11:16 am     Reply with quote

You almost never have to touch registers directly in CCS.
what does setup_timer_0(T0_INTERNAL);.... do?.
FOSC4 is disabled by default.

Best Wishes
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 1:09 pm     Reply with quote

Sorry, but I can`t make it! This is my new program, but this time I have 0 volts on B2:
Code:

#include <10f200.h>
#Fuses NOWDT
#use delay(clock=4M)

void main()
{
   setup_timer_0(T0_INTERNAL);
   output_drive(PIN_B2);
   output_high(PIN_B2);
   while(1);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 2:41 pm     Reply with quote

If you want pin GP2 (PIN_B2) to be an i/o pin, you need to clear the
T0CS bit in the OPTION register. See the example below:
Code:

#include <10F200.h>
#fuses NOWDT, NOMCLR
#use delay(clock=4M)

#define set_options(value)   {#ASM         \
                              MOVLW  value \
                              OPTION       \
                              #ENDASM}
//==========================================
void main()
{
set_options(0xDF);

while(1);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Mon Apr 22, 2013 1:16 am     Reply with quote

The compiler does that for you, unless you have an old version.

Code:

.................... void main()
.................... {
0002:  MOVLW  DF
0003:  OPTION

First two lines of the generated assembler.

The poster hasn't said what compiler version they have. I'd suspect a rather old one....

Best Wishes
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Wed Apr 24, 2013 10:30 am     Reply with quote

My CCS is v4.134. Here is my schematic: http://dox.bg/files/dw?a=7b11e5b117
Do I have a mistake in it?
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PostPosted: Thu Apr 25, 2013 8:58 am     Reply with quote

Try adding a 0.1uf decoupling capp to the VDD line of the pic?
I've been bit in the butt by that causing odd behavior.

Also, my compiler version doesn't support this part so I cannot confirm, but does
Code:
#use delay(clock=4M)

produce the desired setting? Your schematic doesn't show an external crystal so I'd assume you want the internal r/c setting.
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Thu Apr 25, 2013 9:14 am     Reply with quote

The 10F20x chips _only_ operate with the internal oscillator. To save pins. Quote from data sheet:

"The PIC10F200/202/204/206 devices are offered with
Internal Oscillator mode only."

Makes oscillator selection rather easy!....

No possibility of an external crystal.

Agree wholeheartedly on the capacitor. Strange behaviours of all sorts can result if there is not adequate decoupling. Also don't think 'bigger is better' here, and say 'got 470uF on the supply'. Needs to be a capacitor with good HF performance (most electrolytic's do not have good HF perfromance), close to the chip.

Best Wishes
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