Jump to content
RJS

Wireless Bootloader

Recommended Posts

I did not see any posts on this so I do not know if I am just missing something simple or charting a new area. I just started playing with the bootloader from Embedded Adventures and discovered that it can be used wirelessly with an XBee. However, as incredibly exciting as that is, I just have to try to push this one step further. The next step is to get this working without a manual reset or cycling the power. I hoped this would be a simple as calling the reset() function after receiving a specific sequence, but apparently not :angry:

 

As best as I can tell it does appears to go thought the reset ( I also tried forcing the PCL and PCLATH start to 0x0000.) I tried modifying the bootloader to see if it was getting executed and while it seems to be getting to the bootloader code it will not initiate the upload. I have tried a number of different timings incase that was the problem but I still cannot get this to work. I also had the same results with a wired connection.

 

What am I missing?

 

Has anyone already got this to work?

 

Here is the code:

 

#include <system.h>

 

#pragma CLOCK_FREQ 4000000

 

void SendStr( char *p );

 

#pragma DATA _CONFIG1, _CP_OFF & _CCP1_RB3 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF

& _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF

& _INTRC_CLKOUT

 

#pragma DATA _CONFIG2, _IESO_OFF & _FCMEN_OFF

 

#define BAUD 25 /* 9600 */

 

char recdata;

char rmreset;

 

void interrupt()

{

recdata = rcreg;

if( recdata == 'r' )

rmreset = 1;

porta.1 = !porta.1;

}

 

main()

{

unsigned char a;

 

ansel = 0b00000000; // all ports digital

trisa = 0b00100000; // PortA I/O configuration

trisb = 0b00000100; // PortB I/O configuration

osccon = 0b01100000; // Set to 4MHz

porta = 0; // clear ports

portb = 0;

 

// Setup Serial port

spbrg = BAUD; // Set baud rate

txsta = 0b00100110; // transmit enabled async mode, 8 bit high speed baud generator

rcsta = 0b10010000; // enable serial & continous receive

 

// Setup interrupts

intcon = 0b11000000; // Global & Peripheral interrupts on

pie1.RCIE = 1; // interrupts on receive

pir1.RCIF = 0;

 

rmreset = 0;

 

while( 1 )

{

porta.1 = !porta.1;

delay_s( 5 );

if( rmreset )

{

SendStr( "\r\rReset in 10 Seconds\r" );

txsta = 0;

rcsta = 0;

delay_s( 7 );

for( a = 0; a < 10; ++a )

{

porta.1 = !porta.1;

delay_ms( 100 );

}

porta.1 = 0;

asm clrf _pclath

asm clrf _pcl

// reboot();

}

SendStr( "Hello\r" );

 

}

 

}

void SendStr( char *p )

{

while( *p != 0 )

{

while( txsta.TRMT == 0 );

txreg = *p++;

}

 

}

 

Thanks for any suggestions or assistance.

 

RJS

Share this post


Link to post
Share on other sites

If you have the watchdog timer enabled in the config, let it take you back to the reset state. It is very similar to MCLR.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites
If you have the watchdog timer enabled in the config, let it take you back to the reset state. It is very similar to MCLR.

 

Cheers

 

Reynard

 

Reynard,

 

Thanks for the suggestion. It helped to find the source of the problem by changing the timing a bit more and it is now working. It turns out that the problem was disabling the UART before the reset. Taking out the statements

 

txsta = 0;

rcsta = 0;

 

from the reset sequence resolved the problem and I can upload new firmware automatically and wirelessly!

 

Thanks,

 

RJS

Share this post


Link to post
Share on other sites

Sweet! Great work guys. Mind if I make a post about this on the web site?

 

cheers

Ian.

 

If you have the watchdog timer enabled in the config, let it take you back to the reset state. It is very similar to MCLR.

 

Cheers

 

Reynard

 

Reynard,

 

Thanks for the suggestion. It helped to find the source of the problem by changing the timing a bit more and it is now working. It turns out that the problem was disabling the UART before the reset. Taking out the statements

 

txsta = 0;

rcsta = 0;

 

from the reset sequence resolved the problem and I can upload new firmware automatically and wirelessly!

 

Thanks,

 

RJS

Share this post


Link to post
Share on other sites
Sweet! Great work guys. Mind if I make a post about this on the web site?

 

cheers

Ian.

 

If you have the watchdog timer enabled in the config, let it take you back to the reset state. It is very similar to MCLR.

 

Cheers

 

Reynard

 

Reynard,

 

Thanks for the suggestion. It helped to find the source of the problem by changing the timing a bit more and it is now working. It turns out that the problem was disabling the UART before the reset. Taking out the statements

 

txsta = 0;

rcsta = 0;

 

from the reset sequence resolved the problem and I can upload new firmware automatically and wirelessly!

 

Thanks,

 

RJS

 

I do not have any issues with you posting this.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...