www.beck-ipc.com
www.beck-ipc.comwww.beck-ipc.com  | ImprintImprint
FAQFAQ  | SearchSearch  |
  |LoginLogin

RUN STOP switch is not functioning for the first time.

Questions and discussions about the CoDeSys SDK with the IPC@CHIP® plattform.
Hello
I am working on SC24 IEC. I have implemented a RUN/STOP switch. The following changes are made in the myrts code.

Code: Select all
char  RHICTRLGetRunStopSwitch (int *piRun)
{
   /* TO-DO: define here if the function will be supported or not (return value)
    *        and read (and debounce) a signal to decide to stop or run the
    *        IEC-program. e.g. reading of a switch or PIO.
    */
   *piRun = (int)(hal_read_pio(10) & 0x01);
   return 1;  /* Change into 1 (one) if function has to be supported */
}


Code: Select all
unsigned char RHICTRLGetInitStateBootProject (void)
{
   /* TO-DO: Define here the behaviour for a successfully loaded bootproject.
      return RHI_BOOT_RUN to start the bootproject,
      return RHI_BOOT_STOP if the bootproject should not start.
      Here e.g. a switch can be read to make the decision */
   return (hal_read_pio(10) & 0x01) ? RHI_BOOT_RUN: RHI_BOOT_STOP;
   //return RHI_BOOT_RUN;
}


Code: Select all
#pragma argsused
void RHICTRLStateChanged(unsigned char ucState)
{
   /* TO-DO: add here code to react on a start/stop state change, e.g.
      to signal the state using a two Colour LED on a certain hardware
      address
    */
   
   switch(ucState)
         {
            case RHI_STATE_NOPRG:
               outportb(0xC00, 0x00); // switch led off
               break;
            case RHI_STATE_PRGSTARTED:
               pfe_enable_pio(11, 5);
            outportb(0xC00, 0x01); // switch led to green
               break;
            case RHI_STATE_PRGSTOPPED:
               pfe_enable_pio(11, 4);
            outportb(0xC00, 0x02); // switch led to yellow
               break;
         }

}




I am facing a problem while operating the RUN/STOP switch for the first time. The STOP function is not processed when the RUN/STOP switch is STOPED for the first time.
But from the next time onwards it is working fine. Please help me to fix this problem. also if there is any thing wrong in the code please let me know.

Hello

please help me to fix this problem

Return to CoDeSys SDK


Who is online

Users browsing this forum: No registered users and 1 guest


cron