<?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>LPC MicrocontrollersのトピックChip_GPIO_SetPortOutHigh() vs Chip_GPIO_SetPinState()</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-GPIO-SetPortOutHigh-vs-Chip-GPIO-SetPinState/m-p/649923#M25833</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the LPC1768 connected to a ILI9341-based LCD module through a 16-bits data bus and RD/WR/RS control signals. I'm using emWin libraries.&lt;/P&gt;&lt;P&gt;I'm trying to decrease the time the MCU needs to refresh the display. The most important function used by emWin to draw on the display is the following:&lt;/P&gt;&lt;PRE&gt;void LCD_X_8080_16_WriteM01_16(U16 * pData, int NumWords) {
&amp;nbsp; Chip_GPIO_SetPortOutHigh(LPC_GPIO, PORT_LCD_CONTROL, 1 &amp;lt;&amp;lt; PINBIT_LCD_RS);
&amp;nbsp; //Chip_GPIO_SetPinState(LPC_GPIO, PIN_LCD_RS, 1);
&amp;nbsp; for (; NumWords; NumWords--) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; LCD_X_8080_16_Write(*pData);
&amp;nbsp;&amp;nbsp;&amp;nbsp; pData++;
&amp;nbsp; }
}&lt;/PRE&gt;&lt;P&gt;As you can see I'm trying to choose the faster function between&amp;nbsp;Chip_GPIO_SetPortOutHigh() and&amp;nbsp;Chip_GPIO_SetPinState(). In theory,&amp;nbsp;&lt;SPAN&gt;Chip_GPIO_SetPortOutHigh() &amp;nbsp;should be faster because writes directly to .SET register, while&amp;nbsp;Chip_GPIO_SetPinState() reads .SET register, make an OR with a bit, and writes back to .SET.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The output listings demonstrates what I say: the&amp;nbsp;Chip_GPIO_SetPinState() needs an additional instruction.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;STRONG&gt;000009e0 &amp;lt;LCD_X_8080_16_WriteM01_16&amp;gt;: SetPinState&lt;/STRONG&gt;
 9e0: 4b0a ldr r3, [pc, #40] ; (a0c &amp;lt;LCD_X_8080_16_WriteM01_16+0x2c&amp;gt;)
 9e2: 699a ldr r2, [r3, #24]
 9e4: f442 7200 orr.w r2, r2, #512 ; 0x200
 9e8: 619a str r2, [r3, #24]
 9ea: b169 cbz r1, a08 &amp;lt;LCD_X_8080_16_WriteM01_16+0x28&amp;gt;
 9ec: b430 push {r4, r5}
 9ee: 4d08 ldr r5, [pc, #32] ; (a10 &amp;lt;LCD_X_8080_16_WriteM01_16+0x30&amp;gt;)
 9f0: eb00 0141 add.w r1, r0, r1, lsl #1
 9f4: f44f 7280 mov.w r2, #256 ; 0x100
 9f8: f830 4b02 ldrh.w r4, [r0], #2
 9fc: 61da str r2, [r3, #28]
 9fe: 4288 cmp r0, r1
 a00: 802c strh r4, [r5, #0]
 a02: 619a str r2, [r3, #24]
 a04: d1f8 bne.n 9f8 &amp;lt;LCD_X_8080_16_WriteM01_16+0x18&amp;gt;
 a06: bc30 pop {r4, r5}
 a08: 4770 bx lr
 a0a: bf00 nop
 a0c: 2009c000 .word 0x2009c000
 a10: 2009c036 .word 0x2009c036
&amp;nbsp; 
&lt;STRONG&gt;000009d8 &amp;lt;LCD_X_8080_16_WriteM01_16&amp;gt;: SetPortOut&lt;/STRONG&gt;
 9d8: 4b09 ldr r3, [pc, #36] ; (a00 &amp;lt;LCD_X_8080_16_WriteM01_16+0x28&amp;gt;)
 9da: f44f 7200 mov.w r2, #512 ; 0x200
 9de: 619a str r2, [r3, #24]
 9e0: b169 cbz r1, 9fe &amp;lt;LCD_X_8080_16_WriteM01_16+0x26&amp;gt;
 9e2: b430 push {r4, r5}
 9e4: 4d07 ldr r5, [pc, #28] ; (a04 &amp;lt;LCD_X_8080_16_WriteM01_16+0x2c&amp;gt;)
 9e6: eb00 0141 add.w r1, r0, r1, lsl #1
 9ea: f44f 7280 mov.w r2, #256 ; 0x100
 9ee: f830 4b02 ldrh.w r4, [r0], #2
 9f2: 61da str r2, [r3, #28]
 9f4: 4288 cmp r0, r1
 9f6: 802c strh r4, [r5, #0]
 9f8: 619a str r2, [r3, #24]
 9fa: d1f8 bne.n 9ee &amp;lt;LCD_X_8080_16_WriteM01_16+0x16&amp;gt;
 9fc: bc30 pop {r4, r5}
 9fe: 4770 bx lr
 a00: 2009c000 .word 0x2009c000
 a04: 2009c036 .word 0x2009c036&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;However my oscilloscope says&amp;nbsp;Chip_GPIO_SetPinState() is faster than Chip_GPIO_SetPortOutHigh(). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you argue what is the reason?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jan 2017 11:19:06 GMT</pubDate>
    <dc:creator>giusloq</dc:creator>
    <dc:date>2017-01-27T11:19:06Z</dc:date>
    <item>
      <title>Chip_GPIO_SetPortOutHigh() vs Chip_GPIO_SetPinState()</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-GPIO-SetPortOutHigh-vs-Chip-GPIO-SetPinState/m-p/649923#M25833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the LPC1768 connected to a ILI9341-based LCD module through a 16-bits data bus and RD/WR/RS control signals. I'm using emWin libraries.&lt;/P&gt;&lt;P&gt;I'm trying to decrease the time the MCU needs to refresh the display. The most important function used by emWin to draw on the display is the following:&lt;/P&gt;&lt;PRE&gt;void LCD_X_8080_16_WriteM01_16(U16 * pData, int NumWords) {
&amp;nbsp; Chip_GPIO_SetPortOutHigh(LPC_GPIO, PORT_LCD_CONTROL, 1 &amp;lt;&amp;lt; PINBIT_LCD_RS);
&amp;nbsp; //Chip_GPIO_SetPinState(LPC_GPIO, PIN_LCD_RS, 1);
&amp;nbsp; for (; NumWords; NumWords--) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; LCD_X_8080_16_Write(*pData);
&amp;nbsp;&amp;nbsp;&amp;nbsp; pData++;
&amp;nbsp; }
}&lt;/PRE&gt;&lt;P&gt;As you can see I'm trying to choose the faster function between&amp;nbsp;Chip_GPIO_SetPortOutHigh() and&amp;nbsp;Chip_GPIO_SetPinState(). In theory,&amp;nbsp;&lt;SPAN&gt;Chip_GPIO_SetPortOutHigh() &amp;nbsp;should be faster because writes directly to .SET register, while&amp;nbsp;Chip_GPIO_SetPinState() reads .SET register, make an OR with a bit, and writes back to .SET.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The output listings demonstrates what I say: the&amp;nbsp;Chip_GPIO_SetPinState() needs an additional instruction.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;STRONG&gt;000009e0 &amp;lt;LCD_X_8080_16_WriteM01_16&amp;gt;: SetPinState&lt;/STRONG&gt;
 9e0: 4b0a ldr r3, [pc, #40] ; (a0c &amp;lt;LCD_X_8080_16_WriteM01_16+0x2c&amp;gt;)
 9e2: 699a ldr r2, [r3, #24]
 9e4: f442 7200 orr.w r2, r2, #512 ; 0x200
 9e8: 619a str r2, [r3, #24]
 9ea: b169 cbz r1, a08 &amp;lt;LCD_X_8080_16_WriteM01_16+0x28&amp;gt;
 9ec: b430 push {r4, r5}
 9ee: 4d08 ldr r5, [pc, #32] ; (a10 &amp;lt;LCD_X_8080_16_WriteM01_16+0x30&amp;gt;)
 9f0: eb00 0141 add.w r1, r0, r1, lsl #1
 9f4: f44f 7280 mov.w r2, #256 ; 0x100
 9f8: f830 4b02 ldrh.w r4, [r0], #2
 9fc: 61da str r2, [r3, #28]
 9fe: 4288 cmp r0, r1
 a00: 802c strh r4, [r5, #0]
 a02: 619a str r2, [r3, #24]
 a04: d1f8 bne.n 9f8 &amp;lt;LCD_X_8080_16_WriteM01_16+0x18&amp;gt;
 a06: bc30 pop {r4, r5}
 a08: 4770 bx lr
 a0a: bf00 nop
 a0c: 2009c000 .word 0x2009c000
 a10: 2009c036 .word 0x2009c036
&amp;nbsp; 
&lt;STRONG&gt;000009d8 &amp;lt;LCD_X_8080_16_WriteM01_16&amp;gt;: SetPortOut&lt;/STRONG&gt;
 9d8: 4b09 ldr r3, [pc, #36] ; (a00 &amp;lt;LCD_X_8080_16_WriteM01_16+0x28&amp;gt;)
 9da: f44f 7200 mov.w r2, #512 ; 0x200
 9de: 619a str r2, [r3, #24]
 9e0: b169 cbz r1, 9fe &amp;lt;LCD_X_8080_16_WriteM01_16+0x26&amp;gt;
 9e2: b430 push {r4, r5}
 9e4: 4d07 ldr r5, [pc, #28] ; (a04 &amp;lt;LCD_X_8080_16_WriteM01_16+0x2c&amp;gt;)
 9e6: eb00 0141 add.w r1, r0, r1, lsl #1
 9ea: f44f 7280 mov.w r2, #256 ; 0x100
 9ee: f830 4b02 ldrh.w r4, [r0], #2
 9f2: 61da str r2, [r3, #28]
 9f4: 4288 cmp r0, r1
 9f6: 802c strh r4, [r5, #0]
 9f8: 619a str r2, [r3, #24]
 9fa: d1f8 bne.n 9ee &amp;lt;LCD_X_8080_16_WriteM01_16+0x16&amp;gt;
 9fc: bc30 pop {r4, r5}
 9fe: 4770 bx lr
 a00: 2009c000 .word 0x2009c000
 a04: 2009c036 .word 0x2009c036&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;However my oscilloscope says&amp;nbsp;Chip_GPIO_SetPinState() is faster than Chip_GPIO_SetPortOutHigh(). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you argue what is the reason?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jan 2017 11:19:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-GPIO-SetPortOutHigh-vs-Chip-GPIO-SetPinState/m-p/649923#M25833</guid>
      <dc:creator>giusloq</dc:creator>
      <dc:date>2017-01-27T11:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Chip_GPIO_SetPortOutHigh() vs Chip_GPIO_SetPinState()</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-GPIO-SetPortOutHigh-vs-Chip-GPIO-SetPinState/m-p/649924#M25834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please comment the way you are taking this measure in order to replay the issue?Did you test using only this functions?&lt;BR /&gt;Have a great day,&lt;BR /&gt;Sol &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Mar 2017 21:56:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Chip-GPIO-SetPortOutHigh-vs-Chip-GPIO-SetPinState/m-p/649924#M25834</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2017-03-17T21:56:21Z</dc:date>
    </item>
  </channel>
</rss>

