<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>8-bit MicrocontrollersのトピックRe: Bootloader for MC9S08</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169798#M11286</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your interpretation makes sense. Uing BGND instruction to cause ILOP reset makes sense. Debuggers usually use active background mode and&amp;nbsp;BGND will work as a breakpoint while debugging.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On reset variables are'n lost physically, MCU isn't initializing RAM on reset. But ANSI C compiler startup routine initializes&amp;nbsp;all static variables at startup.&amp;nbsp;In Codewarrior to prevent initialization of variable, you should allocate&amp;nbsp;BootloaderEnabled in NO_INIT segment instead of READ_WRITE (see prm file and CW documentation).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Does the MC9S08 have to be in active background mode in order to do self-programming?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No. Anyway you can't enter active background mode without debugger connected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Dec 2010 18:24:05 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2010-12-15T18:24:05Z</dc:date>
    <item>
      <title>Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169796#M11284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am reading a source code for MC9S08 part of which is supposed to respond to a USB bootloading command (the USB wants to flash new code into the microcontroller). When the MC9S08 is in normal user mode, and if it receives a command Cmd_BootloaderEnable from USB port, it is suppose to go into bootloader mode. The program goes like this (if I read the codes correctly):&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;Upon receiving the command from USB, the MC9S08 will set a variable flag &lt;STRONG&gt;&lt;EM style=": ; color: #0000ff;"&gt;BootloaderEnabled = '1'&lt;/EM&gt;&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;2. It then execute &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&lt;EM&gt;BGND&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; command&lt;/P&gt;&lt;P&gt;3. Since the &lt;STRONG&gt;&lt;EM style=": ; color: #0000ff;"&gt;ENBDM&lt;/EM&gt;&lt;/STRONG&gt; is &lt;STRONG&gt;&lt;EM style=": ; color: #0000ff;"&gt;'0'&lt;/EM&gt;&lt;/STRONG&gt;, the instruction &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&lt;EM&gt;BGND&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; is considered&amp;nbsp;illegal and &lt;STRONG&gt;&lt;EM style=": ; color: #0000ff;"&gt;SRS.ILOP&lt;/EM&gt;&lt;/STRONG&gt; will be set to &lt;STRONG&gt;&lt;EM style=": ; color: #0000ff;"&gt;'1'&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;4. MC9S08 reset&lt;/P&gt;&lt;P&gt;5. On start up, it checks whether &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&lt;EM&gt;BootloaderEnabled == '1'&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;, if yes, it jumps to bootloader code&lt;/P&gt;&lt;P&gt;6. USB starts sending bootloading command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does my intepretation make sense?&lt;/P&gt;&lt;P&gt;- What is the pre-requisite for running bootloader (in order to flash new code to the microcontroller)? Does it have to be in active background mode?&lt;/P&gt;&lt;P&gt;- if &lt;STRONG&gt;&lt;EM style=": ; color: #0000ff;"&gt;ENBDM == '0'&lt;/EM&gt;&lt;/STRONG&gt; and &lt;EM&gt;&lt;STRONG style=": ; color: #0000ff;"&gt;BGND&lt;/STRONG&gt;&lt;/EM&gt; is executed, will the microcontroller reset and then go into active background mode? Or it will just do a &lt;SPAN style="color: #0000ff;"&gt;&lt;EM&gt;&lt;STRONG&gt;NOP&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;? If it does reset, the variable flag BootloaderEnable will be lost, right?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 13:48:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169796#M11284</guid>
      <dc:creator>leesp</dc:creator>
      <dc:date>2010-12-15T13:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169797#M11285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does the MC9S08 have to be in active background mode in order to do self-programming?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 18:00:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169797#M11285</guid>
      <dc:creator>leesp</dc:creator>
      <dc:date>2010-12-15T18:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169798#M11286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your interpretation makes sense. Uing BGND instruction to cause ILOP reset makes sense. Debuggers usually use active background mode and&amp;nbsp;BGND will work as a breakpoint while debugging.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On reset variables are'n lost physically, MCU isn't initializing RAM on reset. But ANSI C compiler startup routine initializes&amp;nbsp;all static variables at startup.&amp;nbsp;In Codewarrior to prevent initialization of variable, you should allocate&amp;nbsp;BootloaderEnabled in NO_INIT segment instead of READ_WRITE (see prm file and CW documentation).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Does the MC9S08 have to be in active background mode in order to do self-programming?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No. Anyway you can't enter active background mode without debugger connected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 18:24:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169798#M11286</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-12-15T18:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169799#M11287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear kef,&lt;/P&gt;&lt;P&gt;Thanks for your reply. But I have some questions:&lt;/P&gt;&lt;P&gt;-&amp;nbsp;Since&amp;nbsp;MC9S08 does not need to be in active background mode in order to do self-programming, then why would the code execute BGND command to reset itself?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- You mentioned that one can't enter active background mode without debugger connected. But we just saw that the MCU itself can carry out BGND to put itself into active background mode, without debugger connected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pardon me as I am just a novice and I am confused..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 18:33:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169799#M11287</guid>
      <dc:creator>leesp</dc:creator>
      <dc:date>2010-12-15T18:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169800#M11288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In order for a microcontroller to do self-programming, does it have to be at "boot" time? I mean does the microcontroller have to load user program to its program memory &lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;only&lt;/FONT&gt;&lt;/STRONG&gt; during boot time?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can the microcontroller do this anytime, as long as, say, a button is pressed and the host PC is notified? Can I write&amp;nbsp;a microcontroller code which will poll a pin regularly and check if it is pulled low. If&amp;nbsp;the pin is pulled low, it will go into a subroutine which will listen to read/write command from a host PC, and execute the self-programming accordingly. Then it will be called "anytime-loader" right? Can this be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 18:43:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169800#M11288</guid>
      <dc:creator>leesp</dc:creator>
      <dc:date>2010-12-15T18:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169801#M11289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reset is useful because it's the only right way to reset everything to default state (except reset source bits like ILAF, PORF&amp;nbsp;etc). You may try to reset all registers by hand, but this is error prone, difficult, and doesn't work with write-once registers and bits. And you need to reset if not everything, then at least disable all interrupts that application is enabling. If you reset registers by hand, then either your code is bigger than required (reset all registers or all interrupt enable bits), or it won't work after you some additional interrupt in application. Hardware reset is way more simpler and effective.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BGND works as "enter active backround mode" only if background mode is enabled using debugger. Also I wonder how did you detect than MCU entered active BDM because of BGND instruction?&lt;/P&gt;&lt;P&gt;Try making simple application which just makes&amp;nbsp;LED on or pulses some pin on/off in a loop with BGND instruction. Is it working when powered on with debugger not connected? If yes, then either BGND behaves as NOP or reset. If not, then BGND makes MCU entering active BDM and waiting for instructions from debugger via BDM pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding the&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;only&lt;/FONT&gt;&lt;/STRONG&gt; . It is not required to bootload soon after reset. Flash is always programmable, unless you write protect it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 18:50:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169801#M11289</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-12-15T18:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169802#M11290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks kef, now I am clearer. I will just summarize here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;Reset is to make sure that the bootloader code can run without being interrrupted -&amp;nbsp; to make sure that it is the only program running, otherwise&amp;nbsp;the flash program memory&amp;nbsp;will all be messed up&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;Yes with BGND the processor will only go into active background if ENBDM = '1'. If ENBDM = '0' the processor will reset (I also read somewhere that it will just treat it as a NOP. But nevermind..)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. User code can program the Flash anytime, but it only make sense to&amp;nbsp;program it&amp;nbsp;after reset, for the reason mentioned in 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 21:57:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169802#M11290</guid>
      <dc:creator>leesp</dc:creator>
      <dc:date>2010-12-15T21:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169803#M11291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;UL&gt;&lt;LI&gt;1.&amp;nbsp;Reset is to make sure that the bootloader code can run without being interrrupted -&amp;nbsp; to make sure that it is the only program running, otherwise&amp;nbsp;the flash program memory&amp;nbsp;will all be messed up&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Not only. To reset write-once bits and write-once registers. On some MCU's flash protection register is writeable towards protecting more memory, while unprotecting is not possible. Reset helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;2.&amp;nbsp;Yes with BGND the processor will only go into active background if ENBDM = '1'. If ENBDM = '0' the processor will reset (I also read somewhere that it will just treat it as a NOP. But nevermind..)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;S12(X) family in normal modes have BGND behaving like a multicycle NOP. It can be inserted here and there&amp;nbsp;if one wants fixed address breakpoints while debugging. Recompile for production mode is not required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;3. User code can program the Flash anytime, but it only make sense to&amp;nbsp;program it&amp;nbsp;after reset, for the reason mentioned in&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I prefer reset to enter bootloader from application, but there may be special application requirements. What if there's a need for continuous PWM output, even while reflashing application...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 01:53:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169803#M11291</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-12-16T01:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169804#M11292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;kef wrote:&lt;/FONT&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;2.&amp;nbsp;Yes with BGND the processor will only go into active background if ENBDM = '1'. If ENBDM = '0' the processor will reset (I also read somewhere that it will just treat it as a NOP. But nevermind..)&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;FONT color="#3366FF"&gt;S12(X) family in normal modes have BGND behaving like a multicycle NOP. It can be inserted here and there&amp;nbsp;if one wants fixed address breakpoints while debugging. Recompile for production mode is not required.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;For the 9S08 family, if ENBDM = 0, the BGND instruction will be treated as an illegal opcode, resulting in a reset condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 19:30:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169804#M11292</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2010-12-16T19:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169805#M11293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mac,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right of course. Leesp mentioned that he has read somewhere that BGND is threated as NOP when in normal mode.&amp;nbsp;I guess it was about S12(X).&amp;nbsp;S08 BGND causes ILOP reset when in normal mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 20:31:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169805#M11293</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-12-16T20:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader for MC9S08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169806#M11294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks mac &amp;amp; kef.&lt;/P&gt;&lt;P&gt;I understand now &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Dec 2010 11:05:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Bootloader-for-MC9S08/m-p/169806#M11294</guid>
      <dc:creator>leesp</dc:creator>
      <dc:date>2010-12-17T11:05:57Z</dc:date>
    </item>
  </channel>
</rss>

