6 Replies Latest reply on Sep 27, 2020 11:13 PM by NiBu_4687336

    Coding for CM0

    NiBu_4687336

      Hi.

       

      I have built an application for the CY8CPROTO-062-4343W board. It uses two DMA channels (DMA-1.0 personality of DataWire 0, Channels 20 and 21) to drive a SPI interface (SPI-1.0 personality of SCB 2) to an external ADC device.

       

      Using Modus Toolbox 2.1, it compiles and runs correctly on the CM4 processor. I'm now trying to move that functionality to the CM0+ processor, and have run into some problems.

       

      First is a lack of documentation.

      I have studied

      • Document 002-15656 (Rev. *E), PSoC 6 MCU Dual-CPU System Design
      • Document  002-25617 (Rev.**), PSoC 6 MCU Dual-CPU Basics

      and they contain useful information, but they do not address using ModusToolbox.

       

      I've downloaded and studied these code examples:

      • mtb-example-psoc6-dual-cpu-ipc-sema
      • mtb-example-psoc6-dual-cpu-ipc-pipes
      • mtb-example-psoc6-dual-cpu-empty-app

      The pipes application fails to build, but the other two build without errors. I have successfully loaded and run the semaphore application.

      I modified my Makefile according to what I found in the semaphore app's Makefile. This resulted in these two include paths being left out of the compiler command line:

      • -I./libs/TARGET_CY8CPROTO-062-4343W/COMPONENT_BSP_DESIGN_MODUS
      • -I./libs/TARGET_CY8CPROTO-062-4343W/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource

      This in turn results in the compiler failing to find cycfg_peripherals.h, which results in it failing to find many of the hardware definitions related to the DMA channels and the interface to the external ADC.

       

      My questions are:

      • Is there any documentation on using ModusToolbox to build a dual-core application?
      • What is the secret sauce that will allow me to build my application to talk to my external ADC from the CM0+?
        I'm not concerned (yet) with coordinating the two CPUs, just with compiling my code for the CM0+.

       

      Thanks,

       

      -Nick

        • 1. Re: Coding for CM0
          RodolfoG_11

          Hi Nick,

           

          You can refer to the latest version of the Dual-CPU App Note:

          https://www.cypress.com/file/385711/download

          It explains the steps in detail to enable the CM0+.

           

          By default, the CM0+ does not have access to the BSP_DESIGN_MODUS files, since we expect the customer will only use the CM4.

           

          If you want to enable the design.modus for the CM0+, please add in COMPONENTS= of the CM0+ Makefile the following:

          COMPONENTS=BSP_DESIGN_MODUS

           

          For the ipc-pipes code example, try to open the design.modus for the desired target, save it, and compile it again.

          • 2. Re: Coding for CM0
            NiBu_4687336

            Hi RodolfoG_11

             

            Thanks - that's good information. I tried adding BSP_DEISGN_MODUS to the COMPONENTS variable, and that eliminated the complaint about cycfg_peripherals.h, but replaced it with one about cyhal_hw_types.h. Still, it's progress. I'll read the updated documentation and see if I can figure out where to go next.

            Thanks again,

             

            -Nick

            • 3. Re: Coding for CM0
              RodolfoG_11

              That's because the CM0P app is trying to build the HAL library. The HAL library was designed to only work with CM4.

               

              You have to add the CY_IGNORE in the Makefile to ignore the HAL.

               

              You can refer to the Makefile of the ipc-sema how that is done.

              • 4. Re: Coding for CM0
                NiBu_4687336

                Hi RodolfoG_11.

                 

                That's one of the first things I found in the document you linked. I must say I find the notion of a hardware-specific abstraction layer a bit amusing.

                I've modified my code to eliminate the use of the HAL library. Unfortunately, that also has eliminated interrupts from my ADC. Obviously I'm doing something wrong, but I haven't been able to find an example of configuring an input pin with Device Configurator and hooking its interrupt using the PDL's GPIO functions.

                Thanks,

                 

                -Nick

                • 5. Re: Coding for CM0
                  RodolfoG_11

                  We have updated all our code examples to use HAL. You can refer to the cyhal_adc code itself to see how it is done. It is based on the ADC PDL.

                  • 6. Re: Coding for CM0
                    NiBu_4687336

                    Hi RodolfoG_11.

                     

                    Yes, of course that's what I've done. Unfortunately, and rather inexplicably, the HAL examples choose not to use the tool provided for the purpose of configuring the hardware, the Device Configurator, but instead use hard-coded pin assignments. If this is the only way to configure interrupts, I'll be forced to follow suit, but it feels as though this is something of a step backward.

                    Thanks,

                     

                    -Nick