コード例 #1
0
ファイル: Events.c プロジェクト: RiverLiang/BLDC_180_hall
void PIT_1ms_OnInterrupt(void)
{
  /* Write your code here ... */
	
	  MC33927_GetSR0(& DriverSR0);
	  MC33927_GetSR1(& DriverSR1);
	  MC33927_GetSR2(& DriverSR2);
	  DriverSR3 = MC33927_GetSR3();
}
コード例 #2
0
/*************************************************************************
 * Function Name: MC33927_readStatus
 * Parameters: none
 * Return: none
 * Description: Reads MC33937 driver status registers
 *************************************************************************/
void MC33927_readStatus(void)
{
  /* This command reads Status Register 0 of MC33927 and stores it in the mudtStatusRegister0 structure */
  MC33927_GetSR0(&mudtStatusRegister0);

  /* This command reads Status Register 1 of MC33927 and stores it in the mudtStatusRegister1 structure */
  MC33927_GetSR1(&mudtStatusRegister1);

  /* This command reads Status Register 2 of MC33927 and stores it in the mudtStatusRegister2 structure */
  MC33927_GetSR2(&mudtStatusRegister2);
}
コード例 #3
0
/*************************************************************************
 * Function Name: MC33927_config
 * Parameters: none
 * Return: none
 * Description: Initializes the MC33937 driver
 *************************************************************************/
void MC33927_config(void)
{
    /* This command reads Status Register 0 of MC33927 and stores it in the mudtStatusRegister0 structure */
    MC33927_GetSR0(&mudtStatusRegister0);

    /* This command reads Status Register 1 of MC33927 and stores it in the mudtStatusRegister1 structure */
    MC33927_GetSR1(&mudtStatusRegister1);

    /* This command reads Status Register 2 of MC33927 and stores it in the mudtStatusRegister2 structure */
    MC33927_GetSR2(&mudtStatusRegister2);

    /* This command reads Status Register 3 (deadtime) of MC33927 and stores it in the mbytDeadtime variable */
    MC33927_GetSR3();

    /***** Mode setup *****/
    mudtModeCommands.B.Lock = 0; /* 0: allows further writing; 1: locks the configuration until reset */
    mudtModeCommands.B.FullOnMode = 0; /* 0: BLDC, PMSM, ACIM; 1: SR motors */
    mudtModeCommands.B.DesatFaultMode = 0; /* 0: when desaturation or phase error
                                            on any MOSFET turns off all MOSFETs; 1: desat faults ignored */

    /* This command controls the Desaturation Fault Mode, Full On Mode and Lock Mode bits */
    MC33927_ModeCommand(&mudtModeCommands);

    /***** Interrupts setup *****/
    mudtMaskInterrupts.B.TLim = 0; /* overtemperature interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.Desat = 0; /* dasaturation interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.LowVLS = 0; /* VLS undervoltage interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.Overcurrent = 0; /* overcurrent interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.PhaseError = 0; /* phase error interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.FramingError = 0; /* SPI framing error interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.WriteError = 0; /* write after lock is on interrupt 0: disables; 1: enables */
    mudtMaskInterrupts.B.ResetEvent = 0; /* driver set or disabled interrupt 0: disables; 1: enables */

    /* This command controls interrupt mask registers */
    MC33927_MaskInterrupts(&mudtMaskInterrupts);

    /***** Flags clearing *****/
    mudtClearFlags.B.TLim = 1; /* overtemperature flag 0: untouched; 1: clears */
    mudtClearFlags.B.Desat = 1; /* dasaturation flag 0: untouched; 1: clears */
    mudtClearFlags.B.LowVLS = 1; /* VLS undervoltage flag 0: untouched; 1: clears */
    mudtClearFlags.B.Overcurrent = 1; /* overcurrent flag 0: untouched; 1: clears */
    mudtClearFlags.B.PhaseError = 1; /* phase error flag 0: untouched; 1: clears */
    mudtClearFlags.B.FramingError = 1; /* SPI framing error flag 0: untouched; 1: clears */
    mudtClearFlags.B.WriteError = 1; /* write after lock is on flag 0: untouched; 1: clears */
    mudtClearFlags.B.ResetEvent = 1; /* driver set upon exiting /RST flag 0: untouched; 1: clears */

#if defined __CC_ARM
     for (int ind=0; ind <10000;ind++) __nop();//asm("nop"); // Delay has to be inserted, otherwise 3PPA driver didn't eat the command
    /* This command clears the flag registers */
    MC33927_ClearFlags(&mudtClearFlags);
    for (int ind=0; ind <10000;ind++) __nop();//asm("nop"); // Delay has to be inserted, otherwise 3PPA driver didn't eat the command
#else

    for (int ind=0; ind <10000;ind++) asm("nop"); // Delay has to be inserted, otherwise 3PPA driver didn't eat the command
    /* This command clears the flag registers */
    MC33927_ClearFlags(&mudtClearFlags);
    for (int ind=0; ind <10000;ind++) asm("nop"); // Delay has to be inserted, otherwise 3PPA driver didn't eat the command
#endif
    /* This command sets the zero deadtime */
    MC33927_ZeroDeadtime();

    /* Reading the status registers to check if it was set correctly */
    MC33927_GetSR0(&mudtStatusRegister0); /* SR0 */
    MC33927_GetSR1(&mudtStatusRegister1); /* SR1 */
    MC33927_GetSR2(&mudtStatusRegister2); /* SR2 */
    MC33927_GetSR3(); /* SR3, deadtime value */
}