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

PORT_B_PULLUPS problem

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







PORT_B_PULLUPS problem
PostPosted: Sat Mar 01, 2003 7:14 pm     Reply with quote

I am trying to set the Port B Pull to TRUE and my program consistently hangs. Below is a minimum code segment that displays this. The printf displays if the pullup statement is commented out. Make it active and the nothing and it hangs.

I am using 3.146 under W2K and running on a meLabs X1 board. Equivalent code using PicBasic Pro works fine.


#include <16F877.h>
#use delay(clock=20000000)
#fuses HS,NOWDT
#use RS232(baud=9600, parity=n, bits=8, xmit=PIN_C6, rcv=PIN_C7)
void main() {
setup_adc_ports(NO_ANALOGS);
// port_b_pullups(TRUE);
printf("\fStart Test #3 ");
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12262
sar



Joined: 08 Sep 2003
Posts: 36

View user's profile Send private message

Re: PORT_B_PULLUPS problem
PostPosted: Sat Mar 01, 2003 9:01 pm     Reply with quote

<font face="Courier New" size=-1>Try this:

#include <16F877.h>
#use delay(clock=4000000) //change to 20000000 for your app
#fuses XT,PUT,BROWNOUT,NOWDT //change to HS for your app

#include stdio.h
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BITS=8 )

void display();

void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
port_b_pullups(TRUE);

while(1)
display();
}
void display()
{
printf("fStart Test #3\r\n ");
delay_ms (1000);
}

Will printf once a second with port_b_pullups active TRUE.
SAR</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12263
sar



Joined: 08 Sep 2003
Posts: 36

View user's profile Send private message

Re: PORT_B_PULLUPS problem
PostPosted: Sat Mar 01, 2003 9:08 pm     Reply with quote

<font face="Courier New" size=-1></font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12264
sar



Joined: 08 Sep 2003
Posts: 36

View user's profile Send private message

Re: PORT_B_PULLUPS problem
PostPosted: Sat Mar 01, 2003 9:10 pm     Reply with quote

<font face="Courier New" size=-1></font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12265
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: PORT_B_PULLUPS problem
PostPosted: Sat Mar 01, 2003 11:58 pm     Reply with quote

:=I am trying to set the Port B Pull to TRUE and my program consistently hangs. Below is a minimum code segment that displays this. The printf displays if the pullup statement is commented out. Make it active and the nothing and it hangs.
:=#fuses HS,NOWDT
:=void main() {
:= setup_adc_ports(NO_ANALOGS);
:=// port_b_pullups(TRUE);
:= printf("\fStart Test #3 ");
:=}
------------------------------------------

Add NOLVP to the fuses statement. This will cure the
problem of hanging when pullups are enabled. Example:

#fuses HS, NOWDT, NOLVP

---

You also have another problem, where the last two characters
in your printf() are cut off. You've tried to cure it by
adding two spaces at the end. You don't need to do that.
Instead, add a while(1) loop as the last statement in main().
This will prevent your program from falling off the end of
main(), and hitting the hidden SLEEP instruction that CCS
puts at the end of main().
The SLEEP instruction puts your PIC to sleep while it's still
got your last two chars queued up inside the USART transmitter.

Example:

void main()
{
setup_adc_ports(NO_ANALOGS);
port_b_pullups(TRUE);

printf("\fStart Test #3\n\r"); // Don't need trailing spaces

while(1); // Prevent PIC from going to sleep
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12268
Jerry Finsen
Guest







Re: PORT_B_PULLUPS problem
PostPosted: Sun Mar 02, 2003 7:02 am     Reply with quote

:=Add NOLVP to the fuses statement. This will cure the
:=problem of hanging when pullups are enabled. Example:

Thanks

Bumping my way through the learning curve...
jerry
___________________________
This message was ported from CCS's old forum
Original Post ID: 12272
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