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

Built-in for pull up resistor freezes when in bootloader

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



Joined: 22 Oct 2007
Posts: 21

View user's profile Send private message

Built-in for pull up resistor freezes when in bootloader
PostPosted: Wed Jan 06, 2010 2:33 pm     Reply with quote

I added the following statement to a working version of a bootloader that I am developing:

Code:
port_b_pullups (TRUE); 


I added this to eliminate the need for external pullups. Repeatedly, without this instruction in the bootloader, all works fine (but external pullups are required in this case). With the pull_up built-in, the bootloader freezes ( I am assuming, at this instruction).

I use the same exact built-in once the application starts, and it works fine (on the same hardware that I am testing the bootloader on). So it appears it is something in the bootloader "code environment" that differs from the application "code environment" that is the culprit.

The chip is an 18F8722. I have LVP disabled. Any ideas?

Thanks in advance.

Regards,

Lou
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 06, 2010 4:07 pm     Reply with quote

Put the pullups line at the beginning of main(). Then add a 10us delay
after it to allow time for the pullups to pull up, before it begins executing
any other code. Example:
Code:

void main()
{
// Put variable declarations here.

port_b_pullups(TRUE); 
delay_us(10);
Guest








PostPosted: Wed Jan 13, 2010 7:02 pm     Reply with quote

Thanks for the suggestion. I tried it with no improvement. I know it is freezing exactly at the

port_b_pullups(TRUE) statement

since I light an led at the next statement. With the pull up instruction compiled in, that line is never reached (and of course the bootloader never runs). Without the pullup statement, the led lights and the bootloader works as it should.

Four of the inputs on port B are external interrupt lines. This somehow seems like it might be the troublemaker.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 8:26 pm     Reply with quote

Quote:
Four of the inputs on port B are external interrupt lines.

Disable global interrupts before you enable the Port B pull-ups (if not
already disabled). Then clear each interrupt that you are going to use.
Do this with several clear_interrupt() statements. Then re-enable global
interrupts. Example:
Code:

disable_interrupts(GLOBAL);

port_b_pullups(TRUE);
delay_us(10);   

clear_interrupt(INT_EXT);
clear_interrupt(INT_EXT1);
clear_interrupt(INT_EXT2);
clear_interrupt(INT_EXT3);

enable_interrupts(GLOBAL);
Ttelmah
Guest







PostPosted: Thu Jan 14, 2010 3:15 am     Reply with quote

I'd also do the same for interrupt on change, if this is used anywhere (remember you need to read the port to clear the latch for this one).

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