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

10F202 I/O problem

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



Joined: 04 Aug 2005
Posts: 9

View user's profile Send private message

10F202 I/O problem
PostPosted: Thu Aug 04, 2005 3:39 pm     Reply with quote

Hi!

I'm just playing around with the !0F202, and I cant get det GP2(B2) pin to act as an output, only as an input.. I have made an silly easy code to only blink with some leds to test this..

"
#include "10F202.H"
//#fuses NOBROWNOUT,NOMCLR,NOWDT,NOPROTECT,NOPUT
// Skal benytte 4MHz kystall.
#use delay (clock=4000000)

PORT_B_PULLUPS(TRUE);


void main(void) {

while (TRUE) {

// BLITZ BLÅ LYS

output_bit( PIN_b0, 1);
output_bit( PIN_b1, 0);
output_bit( PIN_b2, 1);

delay_ms (50);

output_bit( PIN_b0, 0);
output_bit( PIN_b1, 1);
output_bit( PIN_b2, 1);


delay_ms (50);


}
}//Slutt main()

"

Using CCS v 3.212

Regards
Svein
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 04, 2005 8:16 pm     Reply with quote

I don't have the PCB compiler, so I can't check the ASM code,
but it's possible that CCS doesn't initialize the OPTION register
properly. Upon power-up reset, the OPTION register is initialized
to all 1's. This will make GP2 into an input. It overrides the
normal TRIS.

To fix this problem, you need to set the T0CS bit in the OPTION
register = 0. This requires ASM code. CCS has a macro for this,
as shown below.

Try adding the following code to your program and see if it works.
I've also set it to enable the pullups, because you showed that
you wanted to do that in your post.
Code:

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

//==============================
void main()
{
// Enable GP2 for i/o, and enable weak pullups.
set_options(0b10011111);   


while(1);
}
SveinR



Joined: 04 Aug 2005
Posts: 9

View user's profile Send private message

PostPosted: Fri Aug 05, 2005 5:25 am     Reply with quote

Okey!! I will try this when I get home from work. THANKS Very Happy

But in that TRIS register, do it control the other pins? And do you set the GP0 an GP1 also as output??

Why wont the SET_TRIS_B comand work?

Regards
SveinR



Joined: 04 Aug 2005
Posts: 9

View user's profile Send private message

PostPosted: Sat Aug 06, 2005 5:06 am     Reply with quote

It works!!! THANKS A LOT Very Happy
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