<?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>topic Re: Dali on MCU in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Dali-on-MCU/m-p/1368769#M46958</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/192071"&gt;@Chish&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks for your patience.&lt;/P&gt;
&lt;P&gt;Regarding your question about "what could be the problem in your code", as I can see, you are probably missing to divide by 100 in the MSB, so, "how can you separate the 324 to MSB=3, MIDB=2, LSB=4" , we would like to suggest you this code snippet that you might use in your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;void stunden (uint32_t hour, uint8_t bit);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;typedef struct{&lt;/P&gt;
&lt;P&gt;uint8_t msb;&lt;/P&gt;
&lt;P&gt;uint8_t midb;&lt;/P&gt;
&lt;P&gt;uint8_t lsb;&lt;/P&gt;
&lt;P&gt;}stunden_t;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;stunden_t g_stunden;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;void stunden (uint32_t hour, uint8_t bit)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;switch (bit)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;case QUERY_STUNDEN_MSB:&lt;/P&gt;
&lt;P&gt;hour /= 100;&lt;/P&gt;
&lt;P&gt;g_stunden.msb = hour;&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case QUERY_STUNDEN_MIDB:&lt;/P&gt;
&lt;P&gt;hour /= 10;&lt;/P&gt;
&lt;P&gt;g_stunden.midb = hour % 10;&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case QUERY_STUNDEN_LSB:&lt;/P&gt;
&lt;P&gt;g_stunden.lsb = hour % 10;&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;default:&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;return;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then you can use this function like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;main.c :&lt;/P&gt;
&lt;P&gt;stunden(324, QUERY_STUNDEN_LSB);&lt;/P&gt;
&lt;P&gt;stunden(324, QUERY_STUNDEN_MIDB);&lt;/P&gt;
&lt;P&gt;stunden(324, QUERY_STUNDEN_MSB);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So this function can return the value that you want for 3 digits, and for 3+ digits you may add to the function the other cases dividing the hour by 1000, 10,000, and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you require more assistance, we would be glad if you let us know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards.&lt;/P&gt;
&lt;P&gt;Pablo Avalos.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Nov 2021 20:09:33 GMT</pubDate>
    <dc:creator>PabloAvalos</dc:creator>
    <dc:date>2021-11-09T20:09:33Z</dc:date>
    <item>
      <title>Dali on MCU</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Dali-on-MCU/m-p/1365776#M46921</link>
      <description>&lt;P&gt;Hi, I'm currently sending hours to Dali Master by breaking it down to 1 byte and sending LSB, MIDB, and MSB. I've attached the picture of my code. the stunden(hour) value is 324. But my logic doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used two logics&lt;/P&gt;&lt;P&gt;Picture mark with 1 is for 3 or higher digits and it doesn't work. When I used the commented part for two digit it works fine but not for 3 digits and above.&lt;/P&gt;&lt;P&gt;Can somebody help me out that what could be the problem in my code? How can I separate the 324 to MSB=3, MIDB=2, LSB=4&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Chish_0-1635948068707.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/161076i610926D76F39F499/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Chish_0-1635948068707.png" alt="Chish_0-1635948068707.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 14:01:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Dali-on-MCU/m-p/1365776#M46921</guid>
      <dc:creator>Chish</dc:creator>
      <dc:date>2021-11-03T14:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dali on MCU</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Dali-on-MCU/m-p/1368769#M46958</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/192071"&gt;@Chish&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks for your patience.&lt;/P&gt;
&lt;P&gt;Regarding your question about "what could be the problem in your code", as I can see, you are probably missing to divide by 100 in the MSB, so, "how can you separate the 324 to MSB=3, MIDB=2, LSB=4" , we would like to suggest you this code snippet that you might use in your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;void stunden (uint32_t hour, uint8_t bit);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;typedef struct{&lt;/P&gt;
&lt;P&gt;uint8_t msb;&lt;/P&gt;
&lt;P&gt;uint8_t midb;&lt;/P&gt;
&lt;P&gt;uint8_t lsb;&lt;/P&gt;
&lt;P&gt;}stunden_t;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;stunden_t g_stunden;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;void stunden (uint32_t hour, uint8_t bit)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;switch (bit)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;case QUERY_STUNDEN_MSB:&lt;/P&gt;
&lt;P&gt;hour /= 100;&lt;/P&gt;
&lt;P&gt;g_stunden.msb = hour;&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case QUERY_STUNDEN_MIDB:&lt;/P&gt;
&lt;P&gt;hour /= 10;&lt;/P&gt;
&lt;P&gt;g_stunden.midb = hour % 10;&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case QUERY_STUNDEN_LSB:&lt;/P&gt;
&lt;P&gt;g_stunden.lsb = hour % 10;&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;default:&lt;/P&gt;
&lt;P&gt;break;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;return;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then you can use this function like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;main.c :&lt;/P&gt;
&lt;P&gt;stunden(324, QUERY_STUNDEN_LSB);&lt;/P&gt;
&lt;P&gt;stunden(324, QUERY_STUNDEN_MIDB);&lt;/P&gt;
&lt;P&gt;stunden(324, QUERY_STUNDEN_MSB);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So this function can return the value that you want for 3 digits, and for 3+ digits you may add to the function the other cases dividing the hour by 1000, 10,000, and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you require more assistance, we would be glad if you let us know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards.&lt;/P&gt;
&lt;P&gt;Pablo Avalos.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 20:09:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Dali-on-MCU/m-p/1368769#M46958</guid>
      <dc:creator>PabloAvalos</dc:creator>
      <dc:date>2021-11-09T20:09:33Z</dc:date>
    </item>
  </channel>
</rss>

