From 5e9187bc7cb972c73207afc588c4c898ad77d074 Mon Sep 17 00:00:00 2001 From: Achala Ram Date: Tue, 3 Oct 2023 15:14:56 +0530 Subject: [PATCH] am64x/am243x: SDFM: Enable Fast detect and Trip zone -Enbale fast detect block -Add support for trip generation Fixes: PINDSW-5510, PINDSW-5523 Signed-off-by: Achala Ram --- .../components/current_sense/current_sense.md | 12 +- .../components/current_sense/sdfm_design.md | 9 ++ .../docs/api_guide/examples/sdfm_example.md | 31 ++++- examples/current_sense/icss_sdfm/app_sdfm.c | 14 ++- examples/current_sense/icss_sdfm/cfg_pad.c | 7 ++ examples/current_sense/icss_sdfm/sdfm.c | 16 ++- examples/current_sense/icss_sdfm/sdfm.h | 6 +- source/current_sense/sdfm/driver/sdfm_drv.c | 37 ++++++ .../current_sense/sdfm/firmware/icssg_sdfm.h | 1 + source/current_sense/sdfm/firmware/sdfm.asm | 118 ++++++++++-------- source/current_sense/sdfm/firmware/sdfm.h | 12 +- source/current_sense/sdfm/firmware/sdfm_bin.h | 103 +++++++++++---- source/current_sense/sdfm/include/sdfm_api.h | 32 +++++ source/current_sense/sdfm/include/sdfm_drv.h | 22 +++- 14 files changed, 320 insertions(+), 100 deletions(-) diff --git a/docs_src/docs/api_guide/components/current_sense/current_sense.md b/docs_src/docs/api_guide/components/current_sense/current_sense.md index 164040d..75dd5ea 100644 --- a/docs_src/docs/api_guide/components/current_sense/current_sense.md +++ b/docs_src/docs/api_guide/components/current_sense/current_sense.md @@ -13,16 +13,22 @@ ICSS %SDFM is a sigma delta interface for phase current measurement in high perf - Normal current (NC) for data read: SINC3 filter with OSR 16 to 256 - Overcurrent (OC) for comparator: free running SINC3 filter with OSR 16 to 256 - Event generation(ARM interrupt for data read from DMEM, GPIO toggle for high and low thresholds) - - High and Low threshold comparator + - Single level High and Low threshold comparator - Trigger based normal current sampling - Double update: Double normal current sampling per EPWM cycle - %SDFM Sync with EPWM + - Fast detect + - PWM Trip generation for overcurrent ## Features Not Supported - Zero cross comparator -- OSR below 16 - Clock phase compensation -- Fast detect and trip generation +- Multi-level threshold + +## System design considerations +### Over Sample Ratio +- OSR Below 16 at SD_CLK greater than 20MHz. The normal current task takes 300ns to 400ns to complete and its execution is based on CMP event and task manager. When we configure OSR below 16 for greater than 20 MHz SD clock, the NC will not be able to complete its processing until the next sample is ready, this will cause the NC samples to be inaccurate. + ## ICSS SDFM Design \subpage SDFM_DESIGN explains the design in detail. diff --git a/docs_src/docs/api_guide/components/current_sense/sdfm_design.md b/docs_src/docs/api_guide/components/current_sense/sdfm_design.md index 937e247..314cb9a 100644 --- a/docs_src/docs/api_guide/components/current_sense/sdfm_design.md +++ b/docs_src/docs/api_guide/components/current_sense/sdfm_design.md @@ -103,6 +103,10 @@ The firmware initiates normal current sampling at the sample trigger point in ea Here ONE_SAMPLE_TIME is: OSR*(1/SD_CLK) \image html SDFM_epwm_sync_and_trigger_timing.png "Sync with EPWM and trigger timing" +#### Fast Detect and Trip generation +The Fast Detect block is used for fast over current detection, it comparatively measures the number of zeros and ones presented in a programmable sliding window of 4 to 32 bits. It starts the comparison after the first 32 sample clocks. Based on the configured zero max/min count limits, it compares zero counter with these limits. If zero counter crosses limit then it sends a error signal to respective PWM Trip zone block. +PWM TZ block receives this error signal and generates a Trip on TZ_OUT pin. + #### AM64x/AM243x EVM Pin-Multiplexing @@ -235,5 +239,10 @@ Here ONE_SAMPLE_TIME is: OSR*(1/SD_CLK) + +
PIN_PRG0_PRU0_GPO16 (J1.7)Comman %SDFM clock input pin
PWM0_TZ_OUT + PIN_PRG0_PRU0_GPO19 + (J5.45)TZ output pin for Axis-1 +
\endcond \ No newline at end of file diff --git a/docs_src/docs/api_guide/examples/sdfm_example.md b/docs_src/docs/api_guide/examples/sdfm_example.md index 26bfa81..b18c9b0 100644 --- a/docs_src/docs/api_guide/examples/sdfm_example.md +++ b/docs_src/docs/api_guide/examples/sdfm_example.md @@ -15,6 +15,8 @@ The ICSS %SDFM example invokes these APIs to - Enable & disable double update - Inform firmware to enable %SDFM mode - Configure GPIO pins for high and low threshold +- Configure fast detect block + Once these steps are executed @@ -258,9 +260,36 @@ Other than the basic EVM setup mentioned in +#include @@ -201,8 +202,10 @@ typedef struct SDFM_ChCtrl_s volatile uint16_t enable_comparator; /**< bit-field to set the output data format for individual SDFM channels, BitN:ChN */ volatile uint16_t output_data_format; - /**< reserved */ - volatile uint16_t reserved1; + /**< bit-field to enable fast detect for individual SDFM channels, BitN:ChN, non-zero to enable */ + volatile uint8_t enFastDetect; + /**< reserved */ + volatile uint8_t reserved1; /**< reserved */ volatile uint16_t reserved2; @@ -254,10 +257,16 @@ typedef struct SDFM_Cfg_s volatile uint8_t osr; /**< sdfm threshold parms*/ SDFM_ThresholdParms sdfm_threshold_parms; - /**< Reserved*/ - volatile uint32_t reserved1; - /**< reserved */ - volatile uint8_t reserved2; + /**< Fast detect window size*/ + volatile uint8_t fd_window; + /**< Fast detect max count of zero*/ + volatile uint8_t fd_zero_max; + /**< Fast detect min count of zero*/ + volatile uint8_t fd_zero_min; + /**< Fast detect max count of one*/ + volatile uint8_t fd_one_max; + /**< Fast detect min count of one*/ + volatile uint8_t fd_one_min; /**< sdfm ch clock parms*/ SDFM_ClkSourceParms sdfm_clk_parms; /**< array to store the params for gpio toggle for different channels*/ @@ -318,6 +327,7 @@ typedef struct SDFM_s { uint8_t iep_inc; SDFM_Interface * p_sdfm_interface; SDFM_SampleOutInterface *sampleOutputInterface; + void *pruss_cfg; } SDFM;