<?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中的主题 HC908QY4 BSET and BCLR inconsistent between POR and RST</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4-BSET-and-BCLR-inconsistent-between-POR-and-RST/m-p/1434291#M23494</link>
    <description>&lt;P&gt;Hi, i hope this is not a repeat post but my browser crashed.....&lt;/P&gt;&lt;P&gt;I have a pile of&amp;nbsp;HC908QY4 so want to use them for a small project.&lt;/P&gt;&lt;P&gt;But I am noticing some odd behaviour which I suspect is related to BSET and BCLR not working as expected. As far as I can see these command won't function until a force a #0ff and then #00 to the port. Then BCLR and BSET seem to work after POR. But then they appear to not work after a RST.&lt;/P&gt;&lt;P&gt;All is OK if I don't need a RST button! But in this case I do...&lt;/P&gt;&lt;P&gt;The code works after a POR, but doesn't after a manual RST. If I replace BSET and BCLR with OR and AND, it seems to operate OK. But they are handy instructions. I wonder if I need to do something elsewhere to correctly initialise the MCU for these instructions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot locate all documents mentioning this - if this was a know snag I would expect it to be documented before now.&lt;/P&gt;&lt;P&gt;It is probably me being dumb, or missing a key initialisation step. My init steps are:&lt;/P&gt;&lt;P&gt;lda #11 ;set COP off and LVI off in CONFIG1&lt;BR /&gt;sta $001f&lt;BR /&gt;lda #01 ;set CONFIG 2 to enable ext RST&lt;BR /&gt;sta $001e&lt;/P&gt;&lt;P&gt;lda #00 ;All inputs for port A&lt;BR /&gt;sta $0004 ;DDR A&lt;BR /&gt;lda #0ff ;All outputs for port B&lt;BR /&gt;sta $0005 ;DDR B&lt;/P&gt;&lt;P&gt;;to make BCLR and BSET functional, I then use this:&lt;BR /&gt;lda #0ff&lt;BR /&gt;sta portb&lt;BR /&gt;lda #00&lt;BR /&gt;sta portb&lt;/P&gt;&lt;P&gt;I'd appreciate any insights as to why a RST is behaving differently to a POR, and why I might be experiencing issues with BSET and BCLR.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 19:15:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-03-25T19:15:03Z</dc:date>
    <item>
      <title>HC908QY4 BSET and BCLR inconsistent between POR and RST</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4-BSET-and-BCLR-inconsistent-between-POR-and-RST/m-p/1434291#M23494</link>
      <description>&lt;P&gt;Hi, i hope this is not a repeat post but my browser crashed.....&lt;/P&gt;&lt;P&gt;I have a pile of&amp;nbsp;HC908QY4 so want to use them for a small project.&lt;/P&gt;&lt;P&gt;But I am noticing some odd behaviour which I suspect is related to BSET and BCLR not working as expected. As far as I can see these command won't function until a force a #0ff and then #00 to the port. Then BCLR and BSET seem to work after POR. But then they appear to not work after a RST.&lt;/P&gt;&lt;P&gt;All is OK if I don't need a RST button! But in this case I do...&lt;/P&gt;&lt;P&gt;The code works after a POR, but doesn't after a manual RST. If I replace BSET and BCLR with OR and AND, it seems to operate OK. But they are handy instructions. I wonder if I need to do something elsewhere to correctly initialise the MCU for these instructions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot locate all documents mentioning this - if this was a know snag I would expect it to be documented before now.&lt;/P&gt;&lt;P&gt;It is probably me being dumb, or missing a key initialisation step. My init steps are:&lt;/P&gt;&lt;P&gt;lda #11 ;set COP off and LVI off in CONFIG1&lt;BR /&gt;sta $001f&lt;BR /&gt;lda #01 ;set CONFIG 2 to enable ext RST&lt;BR /&gt;sta $001e&lt;/P&gt;&lt;P&gt;lda #00 ;All inputs for port A&lt;BR /&gt;sta $0004 ;DDR A&lt;BR /&gt;lda #0ff ;All outputs for port B&lt;BR /&gt;sta $0005 ;DDR B&lt;/P&gt;&lt;P&gt;;to make BCLR and BSET functional, I then use this:&lt;BR /&gt;lda #0ff&lt;BR /&gt;sta portb&lt;BR /&gt;lda #00&lt;BR /&gt;sta portb&lt;/P&gt;&lt;P&gt;I'd appreciate any insights as to why a RST is behaving differently to a POR, and why I might be experiencing issues with BSET and BCLR.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 19:15:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC908QY4-BSET-and-BCLR-inconsistent-between-POR-and-RST/m-p/1434291#M23494</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-25T19:15:03Z</dc:date>
    </item>
  </channel>
</rss>

