Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mark

Pages: 1 [2] 3 4 ... 218
16
Hi All

This example shows how to configure a peripheral pin with help if the _CONFIG_PERIPHERAL() or _CONFIG_PERIPHERAL_LOOPBACK() macros.

As an example I will configure LPSPI3_SCK function on the pin referenced as GPIO_AD_B1_15 (assuming an i.MX RT 106x)


This is the code:

IOMUXC_LPSPI3_SCK_SELECT_INPUT = IOMUXC_LPSPI3_SCK_SELECT_INPUT_GPIO_AD_B1_15_ALT2;
_CONFIG_PERIPHERAL_LOOPBACK(GPIO_AD_B1_15, LPSPI3_SCK, (IOMUXC_SW_PAD_CTL_PAD_PKE | IOMUXC_SW_PAD_CTL_PAD_SPEED_MEDIUM | IOMUXC_SW_PAD_CTL_PAD_DSE_6));


and this is how one arrives at it:

1. One needs to know which GPIO reference (PAD) it is on -> GPIO_AD_B1_15 in this case

2. One searches for this in iMX.h until one finds the list of mux options belonging to it

    #define GPIO_AD_B1_15_FLEXSPIA_SS0_B           (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT0)
    #define GPIO_AD_B1_15_ACMP_OUT03               (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT1)
    #define GPIO_AD_B1_15_LPSPI3_SCK               (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT2)
    #define GPIO_AD_B1_15_SAI1_TX_SYNC             (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT3)
    #define GPIO_AD_B1_15_CSI_DATA02               (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT4)
    #define GPIO_AD_B1_15_GPIO1_IO31               (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5)
    #define GPIO_AD_B1_15_USDHC2_DATA7             (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT6)
    #define GPIO_AD_B1_15_KPP_COL00                (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT7)
    #if defined iMX_RT106X
        #define GPIO_AD_B1_15_ENET2_1588_EVENT3_IN (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT8)
        #define GPIO_AD_B1_15_FLEXIO3_FLEXIO15     (IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT9)
    #endif



3. One take the full mux name (GPIO_AD_B1_15_LPSPI3_SCK) and insert it into the macro, with a comma separating the GPIO reference and the peripheral mux reference belonging to that GPIO:

 _CONFIG_PERIPHERAL_LOOPBACK(GPIO_AD_B1_15, LPSPI3_SCK, (IOMUXC_SW_PAD_CTL_PAD_PKE | IOMUXC_SW_PAD_CTL_PAD_SPEED_MEDIUM | IOMUXC_SW_PAD_CTL_PAD_DSE_6));


This can't be done wrong since it will not compile if incorrect GPIOs aad peripherals are attempted.
The characteristics (last parameter) can be modified to control drive strength and slew rate, etc.

4. Note that either _CONFIG_PERIPHERAL() or _CONFIG_PERIPHERAL_LOOPBACK() is used.
The first is used in most cases but the _CONFIG_PERIPHERAL_LOOPBACK() one is needed for some signals that are generated to be driven onto the pin and also need to be looped back internally to be driven to the peripheral itself. In the case of the LPSPI master operation this MUST be used for the CLK otherwise the clock will be generated but not be connected internally, meaning it won't work completely.

5. Some peripheral pins need an additional sub-muxing setting since they can be located on multiple pins.

IOMUXC_LPSPI3_SCK_SELECT_INPUT = IOMUXC_LPSPI3_SCK_SELECT_INPUT_GPIO_AD_B1_15_ALT2;

To see whether it is necessary it is easiest to search iMX.h for IOMUXC_x (where x is the name of the peripheral signal) -> IOMUXC_LPSPI3_SCK
If it shows up as a IOMUX_xxxx_SELECT_INPUT register, like:

    #define IOMUXC_LPSPI3_SCK_SELECT_INPUT             *(unsigned long *)(IOMUXC_SW_BLOCK + 0x0510) // LPSPI3_SCK_SELECT_INPUT DAISY register
        #define IOMUXC_LPSPI3_SCK_SELECT_INPUT_GPIO_AD_B0_00_ALT7 0x00000000 // select GPIO_AD_B0_00 for mode: ALT7
        #define IOMUXC_LPSPI3_SCK_SELECT_INPUT_GPIO_AD_B1_15_ALT2 0x00000001 // select GPIO_AD_B1_15 for mode: ALT2


it should be set.

IOMUXC_LPSPI3_SCK_SELECT_INPUT = IOMUXC_LPSPI3_SCK_SELECT_INPUT_GPIO_AD_B1_15_ALT2;



One can get away without setting it in case the 0x00000000 is true since it defaults to that, but as good practice it is best to always set the value. It also means that when modifying such configurations one doesn't forget to check and set the value accordingly.

If there is no corresponding IOMUXC_xxxxx_SELECT_INPUT register there is no sub-mux setting to be made.


6. After making such changes one can run the simulator and hover the mouse over the pins one wants to check and it will show the present GPIO/peripheral function so one can easily verify that it is correct before testing on HW.



Regards

Mark

17
NXPTM M522XX, KINETIS and i.MX RT / Re: Compiler Issue
« on: January 24, 2024, 08:13:58 PM »
Hi Neil

I have attached the missing folder as zip file.

Regards

Mark

18
NXPTM M522XX, KINETIS and i.MX RT / Re: Compiler Issue
« on: January 19, 2024, 09:42:03 PM »
Hi Neil

It is a number of years since I last worked with Coldifre and with the CW IDEs, therefore I haven't had any practice for a very long time.
However there is a CW10 project in
\Applications\uTaskerV1.4\CodeWarrior_M522XX_CW10
and the IDE's project settings are in \Applications\uTaskerV1.4\CodeWarrior_M522XX_CW10\ProjectSettings - the content of that folder needs to be copied to the root of the project (above \Applications) and that should allow your to test that the CW 10 or 11 version can build the reference project [I haven't tested this for a very long time so can't guarantee there is not an incompatibility somewhere in the later versions but any issues will be due to prototype changes or new defines needing to be set somewhere, thus easily fixable].

Good luck

Regards

Mark


19
Hi

The selections are in the file app_hw_xxxx.h since it is specific to the HW.
Assuming you are working with an i.MX RT the default tends to be

            #define SDCARD_DETECT_INPUT_INTERRUPT                        // use card detect interrupt rather than polling the card
            #define SDCARD_DETECTION()      ((SDHC_PRSSTAT & SDHC_PRSSTAT_CINST) != 0) // card detection input


and if SDHC_DETECT_INTERRUPT_GPIO is enabled a GPIO can be used instead.

but it can be polled (via GPIO) with

#define SDCARD_DETECT_INPUT_POLL                                 // use card detect switch for detection polling (use together with T_CHECK_CARD_REMOVAL)

or polled by reading an SD card register if neither is enabled.

There is no specific VSEL control for the i.MX RT but if needed it can be added to the POWER_TO_SD_CARD() macro via a GPIO.

Regards

Mark


P.S: Note that the i.MX RT project has only used the SDHC's dedicated card detection line and so I found that I needed to adjust some conditional defines in the mass storage code so that the GPIO interrupt initialisation was included (for example). I have checked these changes in but not tested on HW (only in simulator). I used this on an RT 1020:

            #define SDCARD_DETECT_INPUT_INTERRUPT                        // use card detect interrupt rather than polling the card
            #define SDHC_DETECT_INTERRUPT_GPIO                           // use general GPIO rather than the SDHC's detect input
            #if defined SDHC_DETECT_INTERRUPT_GPIO
                #define SDCARD_DETECT_PORT     PORT2
                #define SDCARD_DETECT_PIN      PIN_GPIO_EMC_00_GPIO2_IO00
                #define PRIORITY_SDCARD_DETECT_PORT_INT     PRIORITY_PORT_2_LOW
                #define SDCARD_DETECTION()      (_READ_PORT_MASK(2, SDCARD_DETECT_PIN) == 0) // card detection input





20
NXPTM M522XX, KINETIS and i.MX RT / Re: UDP socket buffer size
« on: November 10, 2023, 11:19:52 PM »
Hi Neil

As long as the Ethernet Rx buffer can hold the UDP reception it will be adequate - your receive the UDP packet directly in that buffer:

#define LAN_BUFFER_SIZE        1518

is adequate for the largest Ethernet frame (excluding jumbo frames) and so UDP payload (over IPv4) is limited to 1492 bytes (I believe) - this assumes no fragmentation, which will be the case in modern local networks.

Regards

Mark

21
µTasker general / Re: FRDM-K64F FTP
« on: October 25, 2023, 09:09:10 PM »
Hi

The bat file that does this just needs to be double clicked and therefore it is not possible to do anything wrong with the action itself.

However you may have a firewall issue that is allowing the FTP command connection to be established but not the FTP data connection.
Try recording the Ethernet activity with wireshark to see what actually happens and also try temporarily disabling and firewall that you have.

Regards

Mark

22
Hi Ray

Check the user function:

static unsigned char fnIsSelected(unsigned char *ptrBuffer)

This should handle the decision as to whether the particular entry is selected or not but I don't think it is handling the 'C' case.

Try adding something like

case 'C':
if (*ptrBuffer == 'S') { // daylight saving case
    if (the box should be checked) {
        return IS_CHECKED;
    }
}
else if (*ptrBuffer matches the one that is presently selected) { // time zone case assumed
        return IS_SELECTED;                                              // select the entry
}
break;


Regards

Mark

23
Hi Ray

>> #define ACTIVE_FILE_SYSTEM

This is used to enable the uFileSystem which tends to be used with the FTP/HTTP interfaces. However when no Ethernet is enable in the serial loader

#define _NO_FILE_INTERFACE                                           // code size optimisation

is set, which disables some of the support so that the size is optimised.



>> change line 217  from 64 to 476  #define UTASKER_APP_END   (unsigned char *)(UTASKER_APP_START + (476 * 1024)) // use entire chip

You may need to reduce the size by the application's parameter system size so that the parameters are not deleted when loading new code.

Otherwise I haven't been able to reproduce the project so it would be simpler if you send me your config.h and app_hw_kinetis.h files.

If I have understood correctly you are using USE_USB_MSD in the application (a USB-MSD device to SD card / SPI Flash), with the following configuration note:
            #define USE_USB_MSD                                          // needs SD card to compile (or alternatives FLASH_FAT / SPI_FLASH_FAT / FAT_EMULATION)

In the serial loader the same can be set but it looks to be dedicated to the SD card:
#define USE_USB_MSD                                              // full USB-MSD to SD card interface on USB (no emulated loader function) - requires SDCARD_SUPPORT (USB_MSD_DEVICE_LOADER can be disabled)

My initial feeling is that some addition code configuration may be required to allow the same operation.

If you send me the two header files it would be easier for me to check.

Regards

Mark



24
Hi Ray

fnWriteParallelFlash() is only available in the Coldfire project so EXT_FLASH_FILE_SYSTEM should not be defined in the Kinetis project.

Regards

Mark

25
Hi Ray

I don't see the problem by just looking at the configuration.

If I understand correctly you have an application that uses an external SPI memory as FAT media and a host works with it via USB (USB-MSD). Can your application also access the FAT and can it format it? If it can you can use the W25QXXX.ini from the simulation of the application for the serial loader simulation (by copying it to the serial loader's simulation folder). This may help debug the serial loader (when it has a known formatted FAT in the SPI Flash) to see why this is maybe not recognised as the application does. You could check that both application and serial loader are accessing the content at the same address (for example) when both mount the FAT.

Regards

Mark


27
I corrected the double "defined" in the previous post (which was of course incorrect).
Regards
Mark

28
Hi Ray

    #if IP_INTERFACE_COUNT > 1 || IP_NETWORK_COUNT > 1                   // {74}
        #define _TCP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
        #define _TCP_SOCKET_MASK(uSocket)         (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
        #define _UDP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
        #define _UDP_SOCKET_MASK(uSocket)         (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
    #else
        #define _TCP_SOCKET_MASK_ASSIGN(uSocket)
        #define _TCP_SOCKET_MASK(uSocket)         (uSocket)
        #define _UDP_SOCKET_MASK_ASSIGN(uSocket)
        #define _UDP_SOCKET_MASK(uSocket)         (uSocket)

    #endif


When used in a single network/single interface environment the masks become dummy.
However I see that when SNMP is used a further USER_INFO_MASK field is used (in order to control multiple SNMP managers).
My suggestion is that the use of the mask for UDP sockets (not TCP sockets) be forced with:

    #if ((IP_INTERFACE_COUNT > 1) || (IP_NETWORK_COUNT > 1))             // {74}
        #define _TCP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
        #define _TCP_SOCKET_MASK(uSocket)         (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
        #define _UDP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
        #define _UDP_SOCKET_MASK(uSocket)         (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
    #else
        #define _TCP_SOCKET_MASK_ASSIGN(uSocket)
        #define _TCP_SOCKET_MASK(uSocket)         (uSocket)
        #if defined SER_INFO_MASK
            #define _UDP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
            #define _UDP_SOCKET_MASK(uSocket)         (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
        #else

            #define _UDP_SOCKET_MASK_ASSIGN(uSocket)
            #define _UDP_SOCKET_MASK(uSocket)     (uSocket)
        #endif
    #endif
#endif


Thanks for identifying the issue - presumably I always had a mult-network environment when working with SNMP to have missed this.

Regards

Mark

29
Ray

Check that TASK_SNMP is in ctNodes[] in TaskConfig.h

In addition, make sure that you have no new task with the same name.

    {"MsnMp",     fnSNMP,       SMALL_QUEUE, (DELAY_LIMIT)(NO_DELAY_RESERVE_MONO), 0, UTASKER_STOP},


#define TASK_SNMP               'n'                                      // SnMP protocol task

This looks wrong - TASK_SNMP should match the first character of the task's string name.

Try with

    {"nsnMp",     fnSNMP,       SMALL_QUEUE, (DELAY_LIMIT)(NO_DELAY_RESERVE_MONO), 0, UTASKER_STOP},

instead!

Regards

Mark


30
Hi Ray

In ip.c I see that only ARPs directed directly to your IP address are entered so I am not sure that it is appropriate to remove that when ARP_IGNORE_FOREIGN_ENTRIES is enabled.
However the ARP table should not be critical since the worst thing that can happen is that a resolution needs to first be performed when the destination is not yet known.
You can also increase the size of the ARP table so that entries don't need to be deleted when new ones are entere but there is not space for all.

Regards

Mark


Pages: 1 [2] 3 4 ... 218