View previous topic :: View next topic |
Author |
Message |
loupan
Joined: 22 Oct 2007 Posts: 21
|
Built-in for pull up resistor freezes when in bootloader |
Posted: Wed Jan 06, 2010 2:33 pm |
|
|
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
|
|
Posted: Wed Jan 06, 2010 4:07 pm |
|
|
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
|
|
Posted: Wed Jan 13, 2010 7:02 pm |
|
|
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
|
|
Posted: Wed Jan 13, 2010 8:26 pm |
|
|
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
|
|
Posted: Thu Jan 14, 2010 3:15 am |
|
|
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 |
|
|
|