Recent Posts

Pages: 1 ... 6 7 [8] 9 10
71
NXPTM M522XX, KINETIS and i.MX RT / Re: Closing and reopening handles
« Last post by mark on June 21, 2023, 03:24:47 PM »
Hi Neil

You can call with the ucDriverMode set to MODIFY_CONFIG is you want to change the UART settings (such as the baud rate).

The UART doesn't support close and re-open since this is something that is never (up to now) needed in an embedded system. It would be possible since the driver handles a close but it would require the UART's memory management to be changed to use dynamic heap (such as when the buffer sizes need to change) rather than uMalloc() as it presently uses.

If you want to stop the UART for some time you can also do

fnDriver( GSMPortID, ( TX_OFF | RX_OFF ), 0 );

and then later re-enable it with

fnDriver( GSMPortID, ( TX_ON | RX_ON ), 0 );

Regards

Mark

72
NXPTM M522XX, KINETIS and i.MX RT / Closing and reopening handles
« Last post by neil on June 21, 2023, 10:51:30 AM »
Hi Mark,
  Hope you are keeping well..

I call the below to open a Uart and pulse input channels. If I want to call the routine again, do I have to close any handles first? If so how is this done?

Best Regards
Neil

--------------------------

TTYTABLE tGSMInterfaceParameters;                                       // table for passing information to driver
QUEUE_HANDLE fnSetGSMSerialMode(unsigned char ucDriverMode)//
{
    GPTIMER_SETUP gptimer_setup;                                         // interrupt configuration parameters
    tGSMInterfaceParameters.Channel = 1;                            // set UART channel for serial use
    tGSMInterfaceParameters.ucSpeed = SERIAL_BAUD_115200; // baud rate
    tGSMInterfaceParameters.Rx_tx_sizes.RxQueueSize = 400;       // input buffer size
    tGSMInterfaceParameters.Rx_tx_sizes.TxQueueSize = 800;       // output buffer size
//    tGSMInterfaceParameters.Rx_tx_sizes.TxQueueSize = 3000;       // output buffer size Large size as may be used with diagnostics
   
    tGSMInterfaceParameters.Task_to_wake = TASK_GSM;                        // wake self when messages have been received
    tGSMInterfaceParameters.Config = (CHAR_8 | NO_PARITY | ONE_STOP | CHAR_MODE | RTS_CTS |  INFORM_ON_FRAME_TRANSMISSION);
 //   tGSMInterfaceParameters.ucDMAConfig = 0; // NO DMA for UART1

    gptimer_setup.int_type = GPT_TIMER_INTERRUPT;
    gptimer_setup.int_handler = DCDPulse_int;
    gptimer_setup.channel = 1;                                           // general purpose timer channel 1
    gptimer_setup.int_priority = GPTIMER0_INTERRUPT_PRIORITY;            // define interrupt priority
    gptimer_setup.mode = GPT_CAPTURE_RISING_EDGE; // set up capture mode and define the timer clock
                                                                     
    gptimer_setup.usCaptureCount = 0;                         // request this many capture values to be recorded before calling our interrupt
    gptimer_setup.capture_list = 0;                          // the capture list for saving to
   fnConfigureInterrupt((void *)&gptimer_setup);                        // enter interrupt for DMA timer test
    if ((GSMPortID = fnOpen( TYPE_TTY, ucDriverMode, &tGSMInterfaceParameters )) != 0)
     { // open or change the channel with defined configurations (initially inactive)
        fnDriver( GSMPortID, ( TX_ON | RX_ON ), 0 );                  // enable rx and tx
      if (tGSMInterfaceParameters.Config & RTS_CTS) {                   //

            fnDriver( GSMPortID, (MODIFY_INTERRUPT | ENABLE_CTS_CHANGE), 0 ); // activate CTS interrupt when working with HW flow control (this returns also the present control line states)
            fnDriver( GSMPortID, (MODIFY_CONTROL | SET_RTS), 0 );     // activate RTS line when working with HW flow control

        }
     }
         
    return GSMPortID;     
}
73
STTM STM32 and STR91XF / Re: how to configure SPI pins for bootloading (STM32F405)
« Last post by mark on June 14, 2023, 10:30:40 PM »
Hi Alex

If you look in app_hw_stm32.h there are some setups for SDHC and SPI interfaces.

For example:

Code: [Select]
                // Configure to suit SD card SPI mode at between 100k and 400k
                //
                #define SDCARD_CS                  PORTC_BIT11
                #define SDCARD_MISO                PORTB_BIT4
                #define SDCARD_MOSI                PORTB_BIT5
                #define SDCARD_CLK                 PORTB_BIT3
                #define INITIALISE_SPI_SD_INTERFACE() _CONFIG_PORT_OUTPUT(C, SDCARD_CS, (OUTPUT_FAST | OUTPUT_PUSH_PULL)); _SETBITS(C, SDCARD_CS); \
                        POWER_UP(APB1, RCC_APB1ENR_SPI3EN); \
                        _CONFIG_PERIPHERAL_INPUT(B, (PERIPHERAL_SPI3_I2S3ext), (SDCARD_MISO), (INPUT_PULL_UP)); \
                        _CONFIG_PERIPHERAL_OUTPUT(B, (PERIPHERAL_SPI3_I2S3ext), (SDCARD_CLK | SDCARD_MOSI), (OUTPUT_PUSH_PULL | OUTPUT_MEDIUM)); \
                        RCC_APB1RSTR |= RCC_APB1RSTR_SPI3RST; RCC_APB1RSTR &= ~RCC_APB1RSTR_SPI3RST; \
                        SPI3_CR1 = (SPICR1_BR_PCLK2_DIV128 | SPICR1_MSTR | SPICR1_SSI | SPICR1_CPOL | SPICR1_CPHA | SPICR1_SSM); \
                        SPI3_I2SCFGR = 0; \
                        SPI3_CR1 = (SPICR1_SPE | SPICR1_BR_PCLK2_DIV128 | SPICR1_MSTR | SPICR1_SSI | SPICR1_CPOL | SPICR1_CPHA | SPICR1_SSM);

                #define SHARE_SPI                                        // ensure that LCD operations are terminated to avoid conflicts
                #define POWER_UP_SD_CARD()                               // apply power to the SD card if appropriate
                #define ENABLE_SPI_SD_OPERATION()
                // Set maximum speed
                //
                #define SET_SPI_SD_INTERFACE_FULL_SPEED() SPI3_CR1 = (SPICR1_SPE | SPICR1_BR_PCLK2_DIV2 | SPICR1_MSTR | SPICR1_SSI | SPICR1_CPOL | SPICR1_CPHA | SPICR1_SSM)
                #if defined _WINDOWS
                    #define WRITE_SPI_CMD(byte)      SPI3_DR = (unsigned short)byte; SPI3_DR = _fnSimSD_write((unsigned char)byte)
                    #define WAIT_TRANSMISSON_END()   while ((SPI3_SR & SPISR_TXE) == 0) { SPI3_SR |= SPISR_TXE;} \
                                                     while (SPI3_SR & SPISR_BSY) {SPI3_SR &= ~SPISR_BSY;}
                #else
                    #define WRITE_SPI_CMD(byte)      SPI3_DR = (unsigned short)byte
                    #define WAIT_TRANSMISSON_END()   while ((SPI3_SR & SPISR_TXE) == 0) {} \
                                                     while (SPI3_SR & SPISR_BSY)
                #endif
                #define READ_SPI_DATA()              (unsigned char)SPI3_DR

                #define SET_SD_DI_CS_HIGH()           _CONFIG_PORT_OUTPUT(C, SDCARD_MISO, (OUTPUT_FAST | OUTPUT_PUSH_PULL)); _SETBITS(C, SDCARD_MISO); _SETBITS(C, SDCARD_CS) // force DI and CS lines high ready for the initialisation sequence
                #define SET_SD_CARD_MODE()            _CONFIG_PORT_INPUT(C, (SDCARD_MISO), (INPUT_PULL_UP | PULLUP_BIT11));
                #define SET_SD_CS_LOW()               _CLEARBITS(C, SDCARD_CS) // assert the CS line of the SD card to be read
                #define SET_SD_CS_HIGH()              _SETBITS(C, SDCARD_CS) // negate the CS line of the SD card to be read

Using this as reference you can adapt the SPI instance and pins to match your HW.

Regards

Mark

74
STTM STM32 and STR91XF / how to configure SPI pins for bootloading (STM32F405)
« Last post by Alex1982 on June 14, 2023, 06:25:11 PM »
Hello!
I'd like to create an SD bootloader for the STM32F405RGTx except I'm using SPI for the SD card interface, not SDIO

Can you please advise how to proceed to set up SPI card and where to define the SPI pins?

I'm using utaskerSerialBoot V1.4.3 within uVision Keil IDE, compiling fine!

Thanks in advance!

Regards
Alex
75
NXPTM M522XX, KINETIS and i.MX RT / Re: Kinetis K60 Ethernet phy MDIO comm. problem
« Last post by mark on May 31, 2023, 10:41:46 PM »
Hi Ray

I am please that you managed to catch the issue.

Regards

Mark
76
NXPTM M522XX, KINETIS and i.MX RT / Re: Kinetis K60 Ethernet phy MDIO comm. problem
« Last post by Ray on May 31, 2023, 10:38:58 PM »
Hi Mark
I absolutely did not check that  :)   As I was reading thru the pdf manual it was mentioning the default phy address was 00001  4 weak pull downs, one weak pull up.  Yes, my PHY_ADDRESS was defined to 0.   setting to 1 and now I can read phy registers!!   

I've been waiting months to check that one off my list!

Thanks for the help!!

ray
77
NXPTM M522XX, KINETIS and i.MX RT / Re: Kinetis K60 Ethernet phy MDIO comm. problem
« Last post by mark on May 31, 2023, 08:01:57 PM »
Hi Ray

don't forget that the PHY has an address that is set via straps. Make sure that its address matches PHY_ADDRESS.
Or you can try SCAN_PHY_ADD which will scan all possible addresses to see whether the ID can be read on one of them.

Good luck

Regards

Mark

78
NXPTM M522XX, KINETIS and i.MX RT / Re: Kinetis K60 Ethernet phy MDIO comm. problem
« Last post by Ray on May 31, 2023, 03:05:07 AM »
Thanks Mark

It's strange how intellisense is spotty in my VS2022 for this file - but if I double click the kinetis_ENET.h in kinetis.c  the kinetis_ENET.h see's preprocessor info highlighted again.

Unfortunately, I'm still not getting anything but 0xffff when I query the phy registers on the command line. I know my MDIO lines are placed properly this time with a 1.5k p/u I think I need to very carefully attach some skywires to my previous MQX based design to see if MDIO is actually working on MQX code.

 
79
NXPTM M522XX, KINETIS and i.MX RT / Re: Kinetis K60 Ethernet phy MDIO comm. problem
« Last post by mark on May 30, 2023, 10:25:20 PM »
Hi Ray

In kinetis.c

#if (defined ETH_INTERFACE && defined ETHERNET_AVAILABLE && !defined NO_INTERNAL_ETHERNET)
/* =================================================================== */
/*                          Ethernet Controller                        */
/* =================================================================== */
    #include "kinetis_ENET.h"                                            // include Ethernet controller hardware driver code
#endif


It is not possible to include it from a header file since it contains code and then the code would be included in multiple locations.

VS normally handles highlighting well. Try a clean/rebuild which may sort it out.

Regards

Mark
80
NXPTM M522XX, KINETIS and i.MX RT / Kinetis K60 Ethernet phy MDIO comm. problem
« Last post by Ray on May 30, 2023, 08:08:57 PM »
Hi Mark,
As you know I have had moderate success interfacing a DP83848 phy into a uTasker ethernet based application despite the MDIO being inoperative.
As I debug this in the simulator, I can see when kinetis_ENET.h is called to initialize code, but I actually can't find where #include "../../Hardware/Kinetis/kinetis_ENET.h"  is added, so no preprocessor appear to be invoked from the settings in app_hw_kinetis.h, and all variables are flagged as error by the MSVC intellicode. 

If I add like this in the app_hw_kinetis.h
#include "../../Hardware/Kinetis/kinetis.h"                              // include the Kinetis processor header at this location
#include "../../Hardware/Kinetis/kinetis_ENET.h"                       // include the Kinetis processor header at this location

My preprocessor defines correctly highlight with intellicode, but I get hundreds of compiler errors.

Can you tell me where the kinetis_ENET.h is supposed to be #included?

Thanks
Ray

Pages: 1 ... 6 7 [8] 9 10