This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using LIN pins as GPIO

Other Parts Discussed in Thread: HALCOGEN, RM57L843

I am using lintx and linrx as GPIO on RM48L952ZWT. I configured LINTX and LINRX as GPIO pins rather than functional pins through Halcogen.

The problem is, I do not see a specific function in lin.c driver to write/read directly to/from LIN pins as GPIO.

Does this mean I will need to write my own interface function for this or write directly to the DSET or DCLR registers for LIN, which by the way do not exist either. I do see uint32 PIO2; /**< 0x0044 Pin Data In Register */; uint32 PIO3; /**< 0x0048 Pin Data Out Register */

If I set CAN to GPIO, I get:  uint32 canIoRxGetBit(canBASE_t *node); uint32 canIoTxGetBit(canBASE_t *node) etc...

confused...

  • William,

    The header HL_reg_lin.h defines 'linPortx' for example

    /** @def linPORT2

    *   @brief LIN2 GIO Port Register Pointer

    *

    *   Pointer used by the GIO driver to access I/O PORT of LIN2

    *   (use the GIO drivers to access the port pins).

    */

    #define linPORT2 ((gioPORT_t *)0xFFF7E640U)

    You can use this 'linPORTx' parameter as the port number in conjunction with the functions from HL_gio.c/.h:

    void gioSetDirection(gioPORT_t *port, uint32 dir);

    void gioSetBit(gioPORT_t *port, uint32 bit, uint32 value);

    void gioSetPort(gioPORT_t *port, uint32 value);

    uint32 gioGetBit(gioPORT_t *port, uint32 bit);

    uint32 gioGetPort(gioPORT_t *port);

    void gioToggleBit(gioPORT_t *port, uint32 bit);

    This is true for most of the peripherals that have a standard GIO interface,  they use the functions from HL_gio.c/.h to manipulate the pin and they define a 'port' which is the base address of the GIO registers inside the module that you can pass to the gio function.   It works because there's a standard set of GIO registers in most of the peripherals. 

  • I am using device RM48L952ZWT. I found HL_reg_lin.h under device TMS570LC4357ZWT. When I generate code under RM48L952ZWT I do not get a linPORT2. So I am assuming you are pointing out a good start on writing my own functions... Is that correct or am I still confused?
  • William, No, my mistake, I was referencing the RM57L843.
    Anyway the convention is the same. But the RM48 has only a single LIN module, so it's reg_lin.h defines only 'linPORT'.
    On the RM57, there are 2 lin modules, and so it's header defines "linPORT1" and "linPORT2" to distinguish between the two modules.
    Of course you should match the device you are using, I was trying to explain the 'convention'.
  • It was me... I was manipulating the wrong pins... Once I noticed the Pin Locations... I assumed they were 0 and 1... No, they are 1 and 2 or 2U and 4U duh... Thanks!!!
  • Hi
    Im doing the same thing and I already have the LIN TX working, but for some reason the RX pin is not changing its value from 0 to 1... any idea??

    best regards
  • Nope other than to double check everything:
    - bit position you are writing to
    - direction of pin
    - pin function (GIO v.s. LIN)

    Try poking register values through CCS into the LIN pin control registers before you try coding it - it will save you time to exercise the pin manually this way.
  •  

    but I have the LINTX working without problem and I configured both pins as GIO on Halcogen... I already checked the registers... look: the linPORT, 0x4,dir1 works perfectly. but the linPORT, 0x2, dir1 is not working and thats the bit for the LINRX, according to what I saw...

    Best regards

  • Hi Miguel,

    What you pasted above is the source code.

    The thing to do is look directly at the registers using the memory browser in CCS.
  • I already did... but nothing works... I even tried replacing the lin.h, lin.c and reg_lin.h for new ones with the open drain disabled but the RX still not working...

    any clue??