• AVR Freaks

Hot!Additions To Harmony Drivers ?

Author
_pA89
New Member
  • Total Posts : 19
  • Reward points : 0
  • Joined: 2017/06/06 12:39:37
  • Location: India
  • Status: offline
2018/10/27 01:43:19 (permalink)
5 (1)

Additions To Harmony Drivers ?

Harmony Drivers are good, simplify work considerably: These Additions Could Make It Further Better
1) For Lower Power Consumption --- Provision For These in Drivers
     1.1. USD Card: Power Down & Startup at run-time ==> ReInitialize {SPI, SD Card} Drivers at Run-time.
           (Changing SPI Lines Appropriately to Avoid Powering SD Card Via SPI Lines)
     1.2. USB : Power Down in Hardware via PMD(PERIPHERAL MODULE DISABLE) bit
                     ==> ReInitialize USB Drivers at Run-time.
2) Provision for these Simple Drivers (GPIO)
    2.1. Switches: Decoupling Logic
    2.2. LEDS: Single LED can Be Muxed for Functionality{ON, BLINK, FAST BLINK,...}, Can be Used
                     by different application threads, locking of Leds(Cheap Mutex for Efficiency),
                    All Leds Power Down after some time to conserve Power. etc.
3) Provision For Drivers of widely used chips(e.g. bq24074--Charger, bq27441--Fuel Guage, ADXL345--GSensor)
     From External Manufacturers -- To Cut Down Design Time Considerably.
4) "Scaled Down" Version of Harmony Drivers for Operation on PIC23MM Devices
     (Lowest Power Consumption Domain) (I Do Understand f<=25MHz, ROM<=256 KB, RAM<=32KB)
5) Microchip Harmony Windows Port (Just Like FreeRTOS Windows Port) -- Useful For Automated Testing(PIC32 Emulator for Windows?), Coding etc.  Visual  Studio is Professional Tool(i.e. Can Shift Majority of Developmental Work to devenv which is Bliss to Use) 
post edited by _pA89 - 2018/11/09 08:56:56
#1

7 Replies Related Threads

    _pA89
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2017/06/06 12:39:37
    • Location: India
    • Status: offline
    Re: Additions To Harmony Drivers ? 2018/12/30 07:58:01 (permalink)
    0
    6)  Also Data Like {Memory Consumption of OS Variables, Function Cycle Execution Time} must be Provided. Example:
           ----> armKIEL---RL-RTX Technical Data
           ----> armKIEL---RL-RTX Timing Specifications
    #2
    crosland
    Super Member
    • Total Posts : 1569
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: offline
    Re: Additions To Harmony Drivers ? 2018/12/30 13:10:18 (permalink)
    0
    I would suggest raising a support ticket.
    #3
    _pA89
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2017/06/06 12:39:37
    • Location: India
    • Status: offline
    Re: Additions To Harmony Drivers ? 2019/01/11 03:44:25 (permalink)
    0
    I would suggest raising a support ticket.

    Would you get by force(ticket) which you don't get by interest(forum)
    Besides Here is are some examples of what i Have Raised attached below and not completed yet...

    Attached Image(s)

    #4
    qhb
    Superb Member
    • Total Posts : 9985
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: online
    Re: Additions To Harmony Drivers ? 2019/01/11 03:58:42 (permalink)
    0
    _pA89
    I would suggest raising a support ticket.

    Would you get by force(ticket) which you don't get by interest(forum)

    Harmony is maintained by Microchip employees. They work on what they are told to work on, and those directions are determined by information that comes via support requests.
    Yes, the first line of defense in Support seems determined to stop your request going any further, but it's the only official channel (apart from going via a company FAE)
     
    #5
    Jim Nickerson
    User 452
    • Total Posts : 5892
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Additions To Harmony Drivers ? 2019/01/11 07:50:32 (permalink)
    0
    _pA89
    Besides Here is are some examples of what i Have Raised attached below and not completed yet...


    And in the first two instances it was suggested to raise a "NSCAR" request, did you follow the suggestion ?
    #6
    _pA89
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2017/06/06 12:39:37
    • Location: India
    • Status: offline
    Re: Additions To Harmony Drivers ? 2019/04/26 00:41:57 (permalink)
    0
    /*
    >>> CYCLE TIMES(approx): Assuming Single Cycle Execution of Instruction , Jumps -2, MUL,DIV ~20
            Ideal Without Stalls, Slips, Memory Latencies etc.
    + _DRV_SPI_SYS_QUEUE_LockQueue(...) ~ 35(Core) + 20(OSAL_SEM_Pend) ~ 60 SYSCLK Cycles.
    + _DRV_SPI_SYS_QUEUE_AllocElement(...) ~ 85(Core) + 07(SYS_INT_Disable)~ 92 SYSCLK Cycles.
    + _DRV_SPI_SYS_QUEUE_UnockQueue(...) ~ 40(Core) + 20(OSAL_SEM_Post) ~ 60 SYSCLK Cycles.
    + _DRV_SPI_SYS_QUEUE_Dequeue(...) ~ 55(Core) ~ 55 SYSCLK Cycles.
    + DRV_SPI_SYS_QUEUE_Enqueue(...) ~ 45 SYSCLK Cycles.
    + DRV_SPI_SYS_QUEUE_FreeElement(...) ~ 110 SYSCLK Cycles.
    + DRV_SPI_SYS_QUEUE_IsEmpty(...) ~ 10 SYSCLK Cycles.
    + DRV_SPI_SYS_QUEUE_AllocElementLock(...) ~
         40(Core) + 92(_DRV_SPI_SYS_QUEUE_AllocElement(...)) + 60(_DRV_SPI_SYS_QUEUE_LockQueue(...)) + 60(_DRV_SPI_SYS_QUEUE_UnockQueue(...))  ~ 255 SYSCLK 
    + DRV_SPI_SYS_QUEUE_EnqueueLock(...) ~
        40(Core) + 45(DRV_SPI_SYS_QUEUE_Enqueue(...)) + 60(_DRV_SPI_SYS_QUEUE_LockQueue(...)) + 60(_DRV_SPI_SYS_QUEUE_UnockQueue(...)) ~ 205 SYSCLK Cycles.

    + DRV_SPI_Tasks(...) ~ 20 SYSCLK Cycles.
    + IntHandlerSPIInstance0(...) ~ 20 SYSCLK Cycles.
    + DRV_SPI_BufferAdd{Write,Read}2 ~ 155(Core) + 255(Alloc) +205(Enqueue) + 50(memset) + 30(SYS_INT) ~ 700 SYSCLK
    + DRV_SPI_SlaveRMSend8BitISR(...) ~ 140 SYSCLK Cycles
    + DRV_SPI_SlaveRMReceive8BitISR(...) ~ 140 SYSCLK Cycles
    >>> tx = SPI2TX = SPI2 Transfer Done = IRQ-55 //pDrvInstance->txInterruptSource
    >>> rx = SPI2RX = SPI2 Recieve Done = IRQ-54 //pDrvInstance->rxInterruptSource
    >>> err = SPI2E = SPI2 Fault = IRQ-53 //pDrvInstance->errInterruptSource
    */

    //system_interrupts.c
    void IntHandlerSPIInstance0(void) { DRV_SPI_Tasks(sysObj.spiObjectIdx0); }//Interrupt Handler

    //drv_spi.c
    void DRV_SPI_Tasks(SYS_MODULE_OBJ object) {
        struct DRV_SPI_DRIVER_OBJECT * pDrvObject = (struct DRV_SPI_DRIVER_OBJECT *)object;
        (*pDrvObject->vfMainTask)(pDrvObject);//MAPS by User Choice-->DRV_SPI_ISRMaster{RM,EB}8BitTasks
    }
     

    /*drv_spi_master_ebm_tasks.c(Enhanced Buffer) || drv_spi_master_rm_tasks-CONDENSED "FLOWCHART"*/
    int32_t DRV_SPI_ISRMasterRM8BitTasks(struct DRV_SPI_DRIVER_OBJECT * pDrvInstance){// 5 Cycles

       volatile bool continueLoop;//Global Interrupts are not Disabed./* Disable the interrupts */
       SYS_INT_SourceDisable(pDrvInstance->{rx, tx, err}InterruptSource);//6*3~20 Cycles

       do {//Transmission of Single Bytes are not Premptible as they are done in Hardware(in Parallel)
          DRV_SPI_JOB_OBJECT * currentJob = pDrvInstance->currentJob; // 3 Cycles
          SPI_MODULE_ID spiId = pDrvInstance->spiId; // 3 Cycles
          //---------------------1. ---------------------------------------------------------------//
          if (pDrvInstance->currentJob == NULL){/* Check for a new task *///5 Cycles
            if (DRV_SPI_SYS_QUEUE_Dequeue(pDrvInstance->queue, (void *)&(pDrvInstance->currentJob)) != DRV_SPI_SYS_QUEUE_SUCCESS)
                   return 0;//16 + 55 ~ 70 Cycles   /*To Get Current Job to be done out from queue*/
            if (pDrvInstance->currentJob == NULL) { pDrvInstance->txEnabled = false; return 0; }
            currentJob = pDrvInstance->currentJob; pDrvInstance->symbolsInProgress = 0;//11 + 5 Cyc
            /* Call operation starting function pointer.Used to modify the slave select lines */
            DRV_SPI_CLIENT_OBJECT * pClient = (DRV_SPI_CLIENT_OBJECT*)currentJob->pClient;
            if (pClient->operationStarting != NULL)//-->operationStarting //8 Cycles
              (*pClient->operationStarting)(DRV_SPI_BUFFER_EVENT_PROCESSING, (DRV_SPI_BUFFER_HANDLE)currentJob, currentJob->context);//10 + Usr_Begin cycles
           /* Check the baud rate. If its different set the new baud rate*/
           if (pClient->baudRate != pDrvInstance->currentBaudRate){//7 Cycles
              #if defined (PLIB_SPI_ExistsBaudRateClock)//Very Infrequent- Wont Change
               if (pDrvInstance->baudClockSource == SPI_BAUD_RATE_PBCLK_CLOCK)//5 Cycles
                 PLIB_SPI_BaudRateSet(spiId, SYS_CLK_PeripheralFrequencyGet(pDrvInstance->spiClk), pClient->baudRate);//18(Core) + "long Time"
               else // if baud clock source is reference clock
                  PLIB_SPI_BaudRateSet(spiId, SYS_CLK_ReferenceFrequencyGet(CLK_BUS_REFERENCE_1), pClient->baudRate);
              #else
                PLIB_SPI_BaudRateSet(spiId, SYS_CLK_PeripheralFrequencyGet(pDrvInstance->spiClk),  pClient->baudRate);//Not Executed
              #endif
              pDrvInstance->currentBaudRate = pClient->baudRate;//4 Cycles
         } // 4 Cycles
      currentJob->status = DRV_SPI_BUFFER_EVENT_PROCESSING;/* List new job as processing*/
      //###########Only For Enhanced Buffer Mode################
     if (currentJob->dataLeftToTx + currentJob->dummyLeftToTx > PLIB_SPI_RX_8BIT_FIFO_SIZE(spiId)){
       PLIB_SPI_FIFOInterruptModeSelect(spiId, SPI_FIFO_INTERRUPT_WHEN_TRANSMIT_BUFFER_IS_1HALF_EMPTY_OR_MORE);
       PLIB_SPI_FIFOInterruptModeSelect(spiId, SPI_FIFO_INTERRUPT_WHEN_RECEIVE_BUFFER_IS_1HALF_FULL_OR_MORE);
      }
      //###########Only For Enhanced Buffer Mode Ends ################
      PLIB_SPI_BufferClear(spiId);/* Flush out the Receive buffer *///4 +16 ~ 20 Cycles
     }
     //---------------------2. ---------------------------------------------------------------//
     continueLoop = false;/* Execute the sub tasks *///1 Cycle
     if(currentJob->dataLeftToTx + currentJob->dummyLeftToTx != 0)//8 Cycles
      DRV_SPI_MasterRMSend8BitISR(pDrvInstance);//145 Cycles // Enhanced --> RM to EB
      DRV_SPI_ISRErrorTasks(pDrvInstance);//15 Cycles Minimal- No Fault
       /* Figure out how many bytes are left to be received */
       volatile size_t bytesLeft = currentJob->dataLeftToRx + currentJob->dummyLeftToRx;//6 Cycle
       // Check to see if we have any data left to receive and update the bytes left.
      if (bytesLeft != 0){//4 Cycles
        DRV_SPI_MasterRMReceive8BitISR(pDrvInstance);//145 Cycles // Enhanced --> RM to EB
        bytesLeft = currentJob->dataLeftToRx + currentJob->dummyLeftToRx;//6 Cycles
      }
      //---------------------3. ---------------------------------------------------------------//
      if (bytesLeft == 0){//4 cycles
       pDrvInstance->rxEnabled = false;/*Disable interrupt=don't re-enable it later*///2 Cycle
       currentJob->status = DRV_SPI_BUFFER_EVENT_COMPLETE;/* Job is complete*///3 Cycle
    -
       if (currentJob->completeCB != NULL)/* Call the job complete call back*/// 5 Cycles
            (*currentJob->completeCB)(DRV_SPI_BUFFER_EVENT_COMPLETE, (DRV_SPI_BUFFER_HANDLE)currentJob, currentJob->context);//10 + Usr_JobComp Cycles
     
        /* Call the operation complete call back. This is different than the job complete callback.This can be used to modify the Slave Select line. The job complete  callback can be           used to free a client that is blocked waiting for complete*/
       DRV_SPI_CLIENT_OBJECT * pClient = (DRV_SPI_CLIENT_OBJECT*)currentJob->pClient;//3Cycles
       if (pClient->operationEnded != NULL)//-->operationEnding -- 5 cycles
           (*pClient->operationEnded)(DRV_SPI_BUFFER_EVENT_COMPLETE, (DRV_SPI_BUFFER_HANDLE)currentJob, currentJob->context);//10 + Usr_Ending cycle

       if (DRV_SPI_SYS_QUEUE_FreeElement(pDrvInstance->queue, currentJob) != DRV_SPI_SYS_QUEUE_SUCCESS)//10+ 110 Cycles
          return 0;/* Return the job back to the free queue*/// Cycles

       pDrvInstance->currentJob = NULL;/* Clean up *///2 Cycles
       if (!DRV_SPI_SYS_QUEUE_IsEmpty(pDrvInstance->queue)){//11 + 10 Cycles
         continueLoop = true; continue;// 2 + 3 Cycles
        }
       else break;//2 Cycles
      }
        //---------------------4. ---------------------------------------------------------------//
          /* Check to see if the interrupts would fire again if so just go back into the loop instead of suffering the interrupt latency of exiting and re-entering*/
           if (pDrvInstance->currentJob != NULL){ //5 Cycles /* Clear Interrupts*/
               SYS_INT_SourceStatusClear(pDrvInstance->{rx, tx, err}InterruptSource);//3*(7+10)Cycles
                /* Interrupts should immediately become active again if they're in a fired condition */
               //15+3*10 Cycles
              if (SYS_INT_SourceStatusGet(pDrvInstance->{ rx || tx || err }InterruptSource)){
                 /* Interrupt would fire again anyway so we should just go back to the start*/
                continueLoop = true; continue;//2+2 Cycles
              }
            /* If we're here then we know that the interrupt should not be firing again immediately, so re-enable them and exit*/
            SYS_INT_SourceEnable(pDrvInstance->{rx, tx}InterruptSource); return 0;//2*(7+10)+7Cycle
          }
       } while (continueLoop);//5 Cycles
        /* If we're here it means that we have no more jobs in the queue, tx and rx interrupts will be re-enabled by the BufferAdd* functions*/
       SYS_INT_SourceStatusClear(pDrvInstance->{rx, tx}InterruptSource); return 0;//2*(7+10)+7Cycle
    }
     
    int32_t DRV_SPI_SlaveRMSend8BitISR(... object) {
       1. (currentJob == NULL) || (!PLIB_SPI_TransmitBufferIsEmpty())return 0;
       2. PLIB_SPI_BufferWrite(...); dataTxed++; dataLefttoTx--;
      3. SYS_INT_SourceStatusClear(txInterruptSource);
    }
    post edited by _pA89 - 2019/04/26 04:07:37
    #7
    Paul PortSol
    Super Member
    • Total Posts : 430
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Additions To Harmony Drivers ? 2019/04/26 04:41:05 (permalink)
    0
    Would be nice if there was an official wiki for Harmony, where users could post/update
    - notes for various Harmony versions (including warnings, patches)
    - examples
    - methods of using the tools, porting, merging examples into projects, etc.
    - methods of implementing features
    - user created/shared libraries for features not in Harmony, or implemented slightly different from harmony (ring buffers, log files, config files, LED blink, clocks, etc.)
    - user created drivers and code snippets
     
    Bonus if wiki linked to Developer help and forum.
     
    So much gets lots under the weight of the forum history, it can be so difficult to find things.
     
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5