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

12F629 Input Problems. Follow up on earlier thread.

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







12F629 Input Problems. Follow up on earlier thread.
PostPosted: Fri May 02, 2003 1:06 pm     Reply with quote

<font face="Courier New" size=-1>Using the 12F629 I cannot make get the input pin to be stable.
If I program a chip and use this code it works OK.
Pin_A1 has a jumper to ground and if I switch off add the jumper and start up again it also appears to work OK.
However if I now switch off, remove the jumper and switch on again the input reads as 0 !
If I program the chip again it works until I place a jumper on Pin_A1.

I read an earlier thread about this, and tried adding the WPU bits, that does not help.

Has anyone else had this problem.

Best Regards
Hans Wedemeyer

code...

#include <12F629.h>
#use delay(clock=10000000)
#fuses HS,PUT,NOWDT,NOMCLR,NOPROTECT,NOBROWNOUT

#byte WPU = 0x95 // WPU

void main()
{
setup_comparator(NC_NC_NC_NC);
set_tris_A(0X23); // 00100011
port_a_pullups(TRUE);

// with or without this the same thing happens
WPU = 0x03; // pullup for A0, A1

// interrupts disabled etc. here

if ( input(PIN_A1))
{
Mode = LOCAL; // 1 or jumper removed
}
else
{
Mode = REMOTE; // 0 or jumper is in place
}

..... rest of code here

}</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14150
Hans Wedemeyer
Guest







Re: 12F629 Input Problems. Follow up on earlier thread.
PostPosted: Fri May 02, 2003 2:00 pm     Reply with quote

I enabled the Brownout and now it works every time.....

:=#fuses HS,PUT,NOWDT,NOMCLR,NOPROTECT,BROWNOUT
___________________________
This message was ported from CCS's old forum
Original Post ID: 14155
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: 12F629 Input Problems. Follow up on earlier thread.
PostPosted: Fri May 02, 2003 2:07 pm     Reply with quote

:=I enabled the Brownout and now it works every time.....
:=
:=:=#fuses HS,PUT,NOWDT,NOMCLR,NOPROTECT,BROWNOUT
------------------------------------------------


I was looking at your code, and this line might be an issue:
port_a_pullups(TRUE);
The readme.txt file says that for the 12F629, a bitmask
should be used with this function, instead of True/False.
I think that's true, because here's the .LST file code:

<PRE>
.................... port_a_pullups(TRUE);
001D: MOVLW 01 // "TRUE" = 1
001E: BSF 03.5
001F: MOVWF 15 // Write 0x01 to reg 0x95 (WPU reg)
0020: BCF 01.7 // Enable pullups in the Option reg
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14156
Hans Wedemeyer
Guest







Re: 12F629 Input Problems. Follow up on earlier thread.
PostPosted: Fri May 02, 2003 4:48 pm     Reply with quote

Good point, on reading the data sheet I find that ALL WPU are set to Enabled at PowerON and Reset. Which means Setting GPPU in the Option Reg is all that is needed to enable the Pullups. Also setting any TRIS bit to Output will disable the Pull up for that port pin.

I think that the reason it works with port_a_pullups(TRUE) which should also Clear GPPU to enable the pulls.

Anyway I figured my main problem stems from a rough power on and when I enabled the brownout it cured the problem, this I tested 3 time to convince myself it really did cure the problem.

I do like the idea of being able to disable a pullup, it has been a pain on the old pic16's....

From Data Sheet.

At Power ON reset
WPU 95h --11 -111 --11 -111
Which means Clearing GPPU in the OPTION_REG will enable all Pullups for all INPUT pins, no further action is needed.

3.2.1 WEAK PULL-UP
Each of the GPIO pins, except GP3, has an individually
configurable weak internal pull-up. Control bits WPUx
enable or disable each pull-up. Refer to Register 3-3.
Each weak pull-up is automatically turned off when the
port pin is configured as an output.

:=:=I enabled the Brownout and now it works every time.....
:=:=
:=:=:=#fuses HS,PUT,NOWDT,NOMCLR,NOPROTECT,BROWNOUT
:=------------------------------------------------
:=
:=
:=I was looking at your code, and this line might be an issue:
:=port_a_pullups(TRUE);
:=The readme.txt file says that for the 12F629, a bitmask
:=should be used with this function, instead of True/False.
:=I think that's true, because here's the .LST file code:
:=
:=<PRE>
:=.................... port_a_pullups(TRUE);
:=001D: MOVLW 01 // "TRUE" = 1
:=001E: BSF 03.5
:=001F: MOVWF 15 // Write 0x01 to reg 0x95 (WPU reg)
:=0020: BCF 01.7 // Enable pullups in the Option reg
:=</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14157
paulomiranda2



Joined: 01 May 2010
Posts: 1
Location: Brasil

View user's profile Send private message Send e-mail Yahoo Messenger

Re: 12F629 Input Problems. Follow up on earlier thread.
PostPosted: Sat May 01, 2010 12:32 am     Reply with quote

Hans Wedemeyer wrote:
Good point, on reading the data sheet I find that ALL WPU are set to Enabled at PowerON and Reset. Which means Setting GPPU in the Option Reg is all that is needed to enable the Pullups. Also setting any TRIS bit to Output will disable the Pull up for that port pin.

I think that the reason it works with port_a_pullups(TRUE) which should also Clear GPPU to enable the pulls.

Anyway I figured my main problem stems from a rough power on and when I enabled the brownout it cured the problem, this I tested 3 time to convince myself it really did cure the problem.

I do like the idea of being able to disable a pullup, it has been a pain on the old pic16's....

From Data Sheet.

At Power ON reset
WPU 95h --11 -111 --11 -111
Which means Clearing GPPU in the OPTION_REG will enable all Pullups for all INPUT pins, no further action is needed.

3.2.1 WEAK PULL-UP
Each of the GPIO pins, except GP3, has an individually
configurable weak internal pull-up. Control bits WPUx
enable or disable each pull-up. Refer to Register 3-3.
Each weak pull-up is automatically turned off when the
port pin is configured as an output.

:=:=I enabled the Brownout and now it works every time.....
:=:=
:=:=:=#fuses HS,PUT,NOWDT,NOMCLR,NOPROTECT,BROWNOUT
:=------------------------------------------------
:=
:=
:=I was looking at your code, and this line might be an issue:
:=port_a_pullups(TRUE);
:=The readme.txt file says that for the 12F629, a bitmask
:=should be used with this function, instead of True/False.
:=I think that's true, because here's the .LST file code:
:=
:=<PRE>
:=.................... port_a_pullups(TRUE);
:=001D: MOVLW 01 // "TRUE" = 1
:=001E: BSF 03.5
:=001F: MOVWF 15 // Write 0x01 to reg 0x95 (WPU reg)
:=0020: BCF 01.7 // Enable pullups in the Option reg
:=</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14157


Hi , sorry for my english, you have same problem, and I fixed it.
Put in your program this code:

port_a_pullups(63);

Because is necessary a mask to enable any bit to port a , also you enable all pins, and in the own program disabled pins are output or master clear.
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