<?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>MQX Software SolutionsのトピックGPIO problem</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192485#M3845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a character to a specific IO pin but no success . So, I have the following pieces of code (I mention that I have modified the BSP lib in order to have access to this specific pins) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;const uint_32 output_set[] = {    TX_PIN,     TX_ENABLE,       GPIO_LIST_END         };output = fopen("gpio:write", (char_ptr) &amp;amp;output_set);if (output){  SetOutput();}else      printf("Error\n");.......&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the SetOutput function :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void SetOutput(void){   static const uint_32 TxPin[] = {  TX_PIN,  GPIO_LIST_END      };       static const uint_32 TxEnable[] = {  TX_ENABLE,  GPIO_LIST_END     };         ioctl(output, 1, (pointer) &amp;amp;TxPin);    ioctl(output, 1, (pointer) &amp;amp;TxEnable);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Debugging the program , I've seen that it is a problem with fopen function (I think). As you can see in the printscreen attached : it reaches that breakpoint and never steps out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone have an idea ? What I am doing wrong.. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:45:12 GMT</pubDate>
    <dc:creator>Paleantrop</dc:creator>
    <dc:date>2020-10-29T09:45:12Z</dc:date>
    <item>
      <title>GPIO problem</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192485#M3845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a character to a specific IO pin but no success . So, I have the following pieces of code (I mention that I have modified the BSP lib in order to have access to this specific pins) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;const uint_32 output_set[] = {    TX_PIN,     TX_ENABLE,       GPIO_LIST_END         };output = fopen("gpio:write", (char_ptr) &amp;amp;output_set);if (output){  SetOutput();}else      printf("Error\n");.......&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the SetOutput function :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void SetOutput(void){   static const uint_32 TxPin[] = {  TX_PIN,  GPIO_LIST_END      };       static const uint_32 TxEnable[] = {  TX_ENABLE,  GPIO_LIST_END     };         ioctl(output, 1, (pointer) &amp;amp;TxPin);    ioctl(output, 1, (pointer) &amp;amp;TxEnable);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Debugging the program , I've seen that it is a problem with fopen function (I think). As you can see in the printscreen attached : it reaches that breakpoint and never steps out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone have an idea ? What I am doing wrong.. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:45:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192485#M3845</guid>
      <dc:creator>Paleantrop</dc:creator>
      <dc:date>2020-10-29T09:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO problem</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192486#M3846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using magic numbers?&lt;/P&gt;&lt;P&gt;This works for me.&lt;/P&gt;&lt;P&gt;When I send a character I start a timer after setting the enable pin. The timer times out and resets the pin for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define GPIO_IOCTL_WRITE_LOG1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _IO(IO_TYPE_GPIO,0x02)&amp;nbsp; /* Set pins on output port */&lt;BR /&gt;#define GPIO_IOCTL_WRITE_LOG0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _IO(IO_TYPE_GPIO,0x03)&amp;nbsp; /* Clear (set to 0) pins on output port */&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;PRE&gt; GPIO_PIN_STRUCT ch1_ps[] =     {  CH1_TX_ENABLE,  GPIO_LIST_END }; FILE_PTR ch1_enable_fh;......//initializationch1_enable_fh = fopen("gpio:write", ch1_ps );//use in the serial send routine_mqx_int    unc1_putc(uchar c){ _mqx_int err; err = 0; if(socket_flag &amp;amp;&amp;amp; sockfd != NULL) {  err = fputc(c,sockfd); } else if(application_list[HOST_APP] !=0) {  ioctl(ch1_enable_fh, GPIO_IOCTL_WRITE_LOG1, NULL);  err = fputc(c,ch1_fh);  uart1_timer = (40000  / uart1_baud) +1;  while(uart1_timer)   _time_delay(10); } return (err);}//timer times out if(uart1_timer)  if(! -- uart1_timer)  {   ioctl(ch1_enable_fh, GPIO_IOCTL_WRITE_LOG0, NULL);     }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:45:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192486#M3846</guid>
      <dc:creator>boogy</dc:creator>
      <dc:date>2020-10-29T09:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO problem</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192487#M3847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;It seemed to be a hardware problem (not correctly connected to the I/O pins).&lt;/P&gt;&lt;P&gt;Right now, I am trying to send a char using RS-485 (4 wires). So, I have Rx, Tx, RxEnable, TxEnable. Maybe you can give a hint regarding this topic because I think I missed something (based on the fact I am a beginner with MQX).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the defines :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#define TxPin     BSP_TX#define RxPin     BSP_RX#define Tx_Enable BSP_TX_ENABLE#define Rx_Enable BSP_RX_ENABLE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Initialize function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;boolean InitializeIO(void) {    const uint_32 output_set[] = {        TxPin    | GPIO_PIN_STATUS_0,        Tx_Enable | GPIO_PIN_STATUS_0,        Rx_Enable | GPIO_PIN_STATUS_0,        GPIO_LIST_END    };        const uint_32 input_set[] = {        RxPin,        GPIO_LIST_END    };    /* Open and set port as output  */    output_port = fopen("gpio:write", (char_ptr) output_set);    /* Open and set port as input to read value from Rx pin*/    input_port = fopen("gpio:read", (char_ptr) input_set);        if (output_port &amp;amp;&amp;amp; input_port)        return (input_port!=NULL) &amp;amp;&amp;amp; (output_port!=NULL);         else     return 0;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Then I am trying to setup the outputs (for transmitting - RxEnable 1 and TxEnable 1 :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void SetOutput(int signal)
{
   uint_32  set_value=0;
  
   static const uint_32 Send[] = {
    TxPin,
    GPIO_LIST_END
   };
   static const uint_32 SendEnable[] = {
    Tx_Enable,
    GPIO_LIST_END
   };
  
   static const uint_32 ReceiveEnable[] = {
    Rx_Enable,
    GPIO_LIST_END
   };
  
   if(output_port)
   {
           switch(signal)
           {
               case 1: ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, (pointer) &amp;amp;Send);
              
               case 2:
               {
              
                   ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, (pointer) &amp;amp;SendEnable);
                   ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, (pointer) &amp;amp;ReceiveEnable);   
               }
           }
   }
   
  
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;And the trying to send the character :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;int SendChar(uchar c){ _mqx_int error=0;  SetOutput(2); ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, NULL); error = fputc(c,output_port); _time_delay(100); return error;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint ? What I am doing wrong ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&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;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>Thu, 29 Oct 2020 09:45:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/GPIO-problem/m-p/192487#M3847</guid>
      <dc:creator>Paleantrop</dc:creator>
      <dc:date>2020-10-29T09:45:16Z</dc:date>
    </item>
  </channel>
</rss>

