2 Replies Latest reply on Oct 20, 2020 4:38 AM by LePo_1062026

    LIN Block switch to SPI mode

    MoOu_4768141

      Hello everyone,

       

      I generated the Code for a LIN slave in Psoc Creator because my ECU is a LIN slave.

       

      I have an SBC which is connected to the microcontroller and this SBC should be configured during Startup via SPI.

       

      While checking the generated Code I saw that the LIN slave is configured in UART mode and the functions for SPI are not generated.

       

      Could you please let me know, how can I switch to SPI mode to send the commands to the SBC and switch back afterwards to the UART mode to start LIN communication?

       

      Thanks and Regards

        • 1. Re: LIN Block switch to SPI mode
          BragadeeshV_41

          Hi MoOu_4768141,

           

          I assume that you are using a PSoC 4 device in your application. Please correct if I'm wrong.

           

          We do not have direct APIs to switch between LIN and SPI mode. Although you can switch between SPI to I2C/ UART by using unconfigured SCB mode of the SCB component. You can not switch to LIN mode using this method and hence may not be suitable for your application.

           

          In PSoC 4 devices, it is possible to configure the SCB block as an SPI interface (without using an SPI component from the Top design) by using direct register writes. The steps to configure the SCB block as an SPI interface using register writes in detailed in the architecture TRM.  See section Enabling and Initializing SPI section. Detailed explanation of the registers can be found in the respective register TRM.

           

          If you find it difficult to do direct register writes using TRM as reference, you can drag and drop the SPI component and use the generated source to see the right sequence to configure the registers. Make sure to disable the component after you have finished porting the code.

           

          After the SPI functionality is over, reset all the registers and use the LIN component generated APIs (from Top design) to use the SCB block as LIN interface.

           

          Regards,

          Bragadeesh

          • 2. Re: LIN Block switch to SPI mode
            LePo_1062026

            MoOu,

             

            As Bradadeesh pointed out it depends on which PSoC type you are using.

             

            For PSoCs that use SCBs (Serial Communication Blocks), switching between SPI and UART is possible.

            This applies to many PSoC4s and PSoC6s.   The component should list "SCB" in the name or description.

             

            If you are using PSoC3 or PSoC5, UARTs and SPIs are 'custom' built using UDB blocks.  Once the UART or SPI is configured in the TopDesign at design-time, the UDB blocks are programmed for that type of comm component.  Although it is possible to change the UDB blocks at run-time, it is not practical or easy to perform.

             

            With the UDB-style component, you can create BOTH a SPI and a UART and including routing logic so that you can switch between the two in SW.

             

            Len