industrialNETworXnetx

| 23.10.2008 | 09:21 | 2 replies

HIF PIO

Hi, i want to use the HIF PIO in I/O mode.
That's why I wrote this code:

        //IOC_ACCESS_KEY – IO Configuration Access Key Register
        Drv_PioGetInputs(0x00100070, &Test);
        Test=Test & 0x0000FFFF;
        POKE(0x00100070, Test);
        
        //IOC_CR – IO Configuration Mask Register
        POKE_OR(0x00100008, 0x40000000);
        
        //IOC_CR – IO Configuration Mask Register
        POKE_OR(0x00100004, 0x40000000);
 
      
        //IOC_ACCESS_KEY – IO Configuration Access Key Register
        Drv_PioGetInputs(0x00100070, &Test);
        Test=Test & 0x0000FFFF;
        POKE(0x00100070, Test);
        
        //IOC_CR – IO Configuration Register
        Drv_PioGetInputs(0x00100004, &Test1);


After each execution of the program I got a different value of Test1.
I dont know why that is so?

Abslimo

M T

M T

Hilscher Gesellschaft für Systemautomation mbH

| 23.10.2008 | 11:59

Abslimo wrote:

        
        //IOC_ACCESS_KEY – IO Configuration Access Key Register
        Drv_PioGetInputs(0x00100070, &Test);
        Test=Test & 0x0000FFFF;
        POKE(0x00100070, Test);
        
        //IOC_CR – IO Configuration Mask Register
        POKE_OR(0x00100008, 0x40000000);
        
        //IOC_CR – IO Configuration Mask Register
        POKE_OR(0x00100004, 0x40000000);
 
      
        //IOC_ACCESS_KEY – IO Configuration Access Key Register
        Drv_PioGetInputs(0x00100070, &Test);
        Test=Test & 0x0000FFFF;
        POKE(0x00100070, Test);
        
        //IOC_CR – IO Configuration Register
        Drv_PioGetInputs(0x00100004, &Test1);

The upper code is completely wrong.
1. Drv_PioGetInputs expects a handle to a PIO area. Not any absolute address you might have found somewhere in the manual.
2. If you want to use HIF Pios, you won't get far using Drv_Pio. (HIF Pio != PIO). HIF PIO registers, reside in DPMAS Area of the netX memory.
3. You will never update "IO Configuration Mask" (0x100008) register

The IO configuration register has nothing to do with the HIF PIOs, besides enabling Pin multiplexing.
If you want the external HIF Pios enabled you will need to clear Bit31 (0x80000000) in the IO Configuration Register (0x100004). But this only needs to be done once.

  Value = PEEK(0x100004) & ~0x80000000;
  POKE(0x00100070, PEEK(0x00100070));
  POKE(0x00100004, Value);

For using HIF PIOs take a look at the DPMAS chapter in netX Program Reference Guide (DPMAS_IFCONF, DPMAS_IO_XXXX), or use the Drv_HifPio module, which does the upper 3 codes lines internally.

Quote:

After each execution of the program I got a different value of Test1.
I dont know why that is so?

The handle to the call of Drv_PioGetInputs is totally wrong (see point 1). Maybe you should take a look at the sample PIO (rcX-based) and HifPIO(lowest C-Level) examples which are freely available on the Homepage.

Regards

MT

| 23.10.2008 | 15:03

Thanks

Abslimo

Login