|
brazos-trapezoidal
|
Main file. More...

Go to the source code of this file.
Macros | |
| #define | SPI_CLK PIN_PC1 |
| #define | SPI_SS PIN_PC0 |
| #define | SPI_MISO PIN_PC3 |
| #define | SPI_MOSI PIN_PC2 |
| #define | SPI_CLK_CFG XBAR_CTL_CFG_1 |
| #define | SPI_SS_CFG XBAR_CTL_CFG_1 |
| #define | SPI_MISO_CFG XBAR_IN_SPI_CFG_IN_MISO_PC3 |
| #define | SPI_MOSI_CFG XBAR_CTL_CFG_1 |
| #define | UART0_TX PIN_PB4 |
| #define | UART0_RX PIN_PB5 |
| #define | UART1_TX PIN_PR4 |
| #define | UART1_RX PIN_PR3 |
| #define | TIM_CLK_DIV 1 |
| #define | TIM1_PER 3020 |
| #define | ADC_SAMPLE_PERIOD 7 |
Functions | |
| void | GpioXbarSetup (void) |
| Gpio and crossbar function initialization . More... | |
| void | AdcSetup (void) |
| Adc configuration function. Called by main_init function. More... | |
| void | DmaSetup (void) |
| Dma configuration function. Called by main_init function. More... | |
| void | TimerPwmSetup (uint8_t ADC_Advance, uint16_t ADC_Advance_Delay_Syslks) |
| Pwm configuration function. Called by main_init function. More... | |
| void | TimerSync (uint8_t SawUp) |
| Timer sync up function between TIM0 and TIM2. Called by TIM0Event function. More... | |
| void | SpiInit (void) |
| Spi init function - (debug purposes). Called by main_init function. More... | |
| void | UartSetup (void) |
| Uart setup funtion. Called by main_init function. More... | |
| void | main_10ms (void) |
| Main handler of 10ms. Called at a while(1) infinite loop at main(). Time controlled by a flag - slot_10ms. More... | |
| void | main_count_1ms (void) |
| Main 1ms handler inside dma event function. Called by DMA_Event function. More... | |
| bool | UART0Event (uint32_t event) |
| Uart0 Event function. More... | |
| bool | UART1Event (uint32_t event) |
| Uart1 Event function. More... | |
| void | SysTickCallBack (void) |
| Systick call back function Passed as argument of systick_initialize function at TimerInterrut.c Call rate of 250 us. More... | |
| void | TIM0Event (uint32_t event) |
| Tim0 Event function Passed as argument of tim_initialize function;. More... | |
| void | TIM2Event (uint32_t event) |
| Tim2 Event function Passed as argument of tim_initialize function;. More... | |
| void | PWM0Event (uint32_t event) |
| Pwm0 Event function Passed as argument of pwm_initialize function;. More... | |
| void | PWM3Event (uint32_t event) |
| Pwm3 Event function Passed as argument of pwm_initialize function;. More... | |
| void | PWM1Event (uint32_t event) |
| Pwm1 Event function Passed as argument of pwm_initialize function;. More... | |
| void | PWM2Event (uint32_t event) |
| Pwm2 Event function Passed as argument of pwm_initialize function;. More... | |
| void | DMA_Event (uint32_t event) |
| Dma Event function Passed as argument of dma_initialize function;. More... | |
| void | ErrorEvent (uint32_t event) |
| Error Event function for Dma Passed as argument of dma_initialize function;. More... | |
| void | WDogEvent (uint32_t event) |
| Watchdog Event function Passed as argument of wdog_initialize function;. More... | |
| void | main_step (void) |
| Main step function (FOR SIMULATION ONLY). Executes at control rate of 4KHz. More... | |
| void | main_init (void) |
| Main initialization function . Executes at start of main function. More... | |
| int | main (void) |
| Main function. More... | |
| void | HardFault_Handler (void) |
| Hard fault handler. Cause reset due while(1) More... | |
| void | main__Start_Motor (int16_t speed, int16_t accel) |
| Main motor start function. More... | |
| void | main__Stop_Motor (void) |
| Main motor stop function. More... | |
| void * | main__pointerUart0 () |
| Get the uart0 configuration pointer. Used by Serial Buffer module. More... | |
Variables | |
| uint16_t | ADC_Samples [NUM_ADC_SAMPLES] |
| uint32_t | ADC_CTL_ptr [NUM_ADC_SAMPLES] |
| volatile uint32_t | TIM0_PER |
| volatile uint8_t | Sync_Timer02 |
| volatile uint8_t | Saw_Up |
| uint16_t | AdvDelay |
| uint32_t | SPIData [5] |
| volatile unsigned short | TimerOut1s = 100 |
| volatile uint8_t | TimerOutFlashOperation = 0 |
| volatile uint8_t | count_10ms = 0 |
| volatile uint8_t | slot_10ms = false |
| volatile uint8_t | Counter1KHz |
| volatile uint8_t | DmaEnableRequest = 1 |
| void * | pTim0 |
| void * | pTim1 |
| void * | pTim2 |
| void * | pPwm0 |
| void * | pPwm1 |
| void * | pPwm3 |
| void * | pPwm2 |
| void * | pUart0 |
| void * | pUart1 |
| bool | bTxDone = false |
| bool | bRxDone = false |
| volatile int32_t | TestBldcSpd = 350 |
| volatile int32_t | TestBldcRamp = 50 |
| volatile uint16_t | TestBldcUpdtSpdTimer = 1000 |
| volatile uint8_t | TestBldcUpdtSpdReq = 0 |
| unsigned char | TestBldcOn = 0 |
| unsigned char | TestBldcOff |
| #define ADC_SAMPLE_PERIOD 7 |
| #define SPI_CLK PIN_PC1 |
| #define SPI_MISO_CFG XBAR_IN_SPI_CFG_IN_MISO_PC3 |
| #define SPI_MOSI_CFG XBAR_CTL_CFG_1 |
| #define SPI_SS_CFG XBAR_CTL_CFG_1 |
| #define TIM1_PER 3020 |
| #define TIM_CLK_DIV 1 |
| #define UART1_RX PIN_PR3 |
| void AdcSetup | ( | void | ) |
Adc configuration function. Called by main_init function.
For all channels.
Continuous conversions: 0x00000006. For single count: 0x00000005
CNT_LIMIT [18:8]: 0x0 Count limit is set to 0
Reserved [7] : 0x0
SEQ [6] : 0x0 0: Reset the channel sequence to start at the lowest enabled channel. Self clearing
EDGE_TRIG [5:4] : 0x0 on rising edge
AHW_TRIG [3] : 0x0
OVER_EN [2] : 0x1 ADC over write enabled
CONT_EN [1] : 0x1 Continuous mode enabled
CNT_EN [0] : 0x0 Count mode disabled.
< For last converted channel HW Trigger Rise Edge 0x0000004D CNT_LIMIT [18:8]: 0x1 Count limit is set to 1 Reserved [7] : 0x0 SEQ [6] : 0x0 1: Reset the channel sequence to start at the lowest enabled channel. Self clearing EDGE_TRIG [5:4] : 0x0 on rising edge AHW_TRIG [3] : 0x1 trigger ADC StartConversion on rising edge of hardware signal - continuous mode OVER_EN [2] : 0x1 ADC over write enabled CONT_EN [1] : 0x0 Continuous mode disabled, ahw will manage trigger. CNT_EN [0] : 0x1 Count mode enabled, number of conversions is CNT_LIMIT+1.
< CH0 as analog pin
< CH0 no pull down
< CH1 as analog pin
< CH1 no pull down
< CH2 as analog pin
< CH2 no pull down
< CH3 as analog pin
< CH3 no pull down
< CH4 as analog pin
< CH4 no pull down
< CH5 as analog pin
< CH5 no pull down
< CH6 as analog pin
< CH6 no pull down
< CH7 as analog pin
< CH7 no pull down
< AVDD regulator Internal Compensation
< Single Range Selection, 2 times VREF
< Select ADC internal reference source - VDDIO over 2
< Select ADC reference voltage - Internal
< Select ADC gain multiplier - times 1
< ADC sampling with gain amplification is giving by: 6 ADC_CLK + (ADC_SAMPLE_PERIOD + 7ADC_CLK) = 20 ADC_CLK (500ns) @ADC_CLK=40MHz
< Set channel as single ended
< Set channel as single ended
< Set channel as single ended
< Set channel as single ended
< Set channel as single ended
< Set channel as single ended
< Set channel as single ended
< Set channel as single ended
< ADC over-write (of data and channel number) enabled
< ADC continuous mode disabled
< ADC count conversion enable. Self clearing when number of requested conversion (CNT_LIMIT + 1) are done. Writing 1 will abort current sequence
< ADC CNT_LIMIT set to zero
< ADC interrupt enabled
< ADC Trigger set as PWM0
< XBAR ADC trigger type set as TIM source, pwm0
< Edge trigger on the rising edge
< AHW trigger source enabled
< Continuous mode enabled
< ADC interrupt priority set to highest
< AHW trigger source enabled
< ADC over-write (of data and channel number) disabled
< ADC interrupt disabled
| void DMA_Event | ( | uint32_t | event | ) |
| void DmaSetup | ( | void | ) |
| void ErrorEvent | ( | uint32_t | event | ) |
| void GpioXbarSetup | ( | void | ) |
| void HardFault_Handler | ( | void | ) |
| int main | ( | void | ) |
| void main_10ms | ( | void | ) |
Main handler of 10ms. Called at a while(1) infinite loop at main(). Time controlled by a flag - slot_10ms.
< Service the watchdog
< Decrement 1s timer
< Toggle leds at 1s rate
< Reload 1s timer
< Check for a request on flash parameter access (write, read, post write)
< Access to flash only possible with motor stopped
< Motor is stopped if it was running and after 1s
Definition at line 558 of file main.c.


| void * main__pointerUart0 | ( | ) |
| void main__Start_Motor | ( | int16_t | speed, |
| int16_t | accel | ||
| ) |
| void main_count_1ms | ( | void | ) |
| void main_init | ( | void | ) |
Main initialization function . Executes at start of main function.
< XBAR peripheral initialization
< GPIO peripheral initialization
< LSI initialization
< Microcontroller clocks initialization
< Timer Interrupt (Systick) initialization
< Calibration initialization
< Trapezoidal motor control initialization
< LEDs at off condition
< LEDs at off condition
< DMA enable request is set to true, enable it, when appropriate
< Analog to Digital converter configuration
< Dma configuration
< TIM0 is the pwm timer and its timer period is set for 40MHz clock with 16KHz operation. As it is triangular counter, the equation is divided by 2
< AdvDelay is the location of the pwm trigger, which is the peak of the triangular counter of pwm with a delay of 83 counts, or 2.1 [us], at 40MHz
< Setup the pwm (timers, pins and interrupts)
< ADC sequence is reset to get started
< Uart configuration - UART0 (PC interface) and UART1 (Jlink on board)
< API006MemoryRW module configuration
< API023MotorControl module configuration
< Tsp module configuration (Theta serial protocol)
< watchdog module initialization
< Enable write access to all other registers by writing 0x1ACCE551
< Update the value of 32-bit LOAD register - 64MHz counter targeting 150ms 64000000*0.150 = 9600000
< Reloads the counter from the value in WDOG LOAD
< Enable the interrupt event, WDOGINT. Set HIGH to Enable the counter and the interrupt
< Enable Watchdog reset output, WDOGRES. Set HIGH to enable the reset
< Disable write access by writing any other value than 0x1ACCE551
< Service the watchdog
< Tick timer for Bemf counting - free running counter
< Initialize Tick Timer as Free Runner Counter for Bemf time counting - 40MHz counter
< Set the source clock of the tick counter as HSOC = 40MHz
< Set the multiplier of clock of the tick counter as 1
Definition at line 489 of file main.c.


| void main_step | ( | void | ) |
| static void PWM0Event | ( | uint32_t | event | ) |
| static void PWM1Event | ( | uint32_t | event | ) |
| static void PWM2Event | ( | uint32_t | event | ) |
| static void PWM3Event | ( | uint32_t | event | ) |
| void SpiInit | ( | void | ) |
| void SysTickCallBack | ( | void | ) |
| void TIM0Event | ( | uint32_t | event | ) |
| void TIM2Event | ( | uint32_t | event | ) |
| void TimerPwmSetup | ( | uint8_t | ADC_Advance, |
| uint16_t | ADC_Advance_Delay_Syslks | ||
| ) |
Pwm configuration function. Called by main_init function.
| ADC_Advance | - (0) for synchronization at Saw count up of TIM2 (1) for synchronization at Saw count down of TIM2 |
| ADC_Advance_Delay_Syslks | - pwm count clocks to trigger the adc sampling |
Definition at line 856 of file main.c.

| void TimerSync | ( | uint8_t | SawUp | ) |
| bool UART0Event | ( | uint32_t | event | ) |
| bool UART1Event | ( | uint32_t | event | ) |
| void UartSetup | ( | void | ) |
| void WDogEvent | ( | uint32_t | event | ) |
| uint32_t ADC_CTL_ptr[NUM_ADC_SAMPLES] |
| uint16_t ADC_Samples[NUM_ADC_SAMPLES] |
| bool bRxDone = false |
| volatile uint8_t count_10ms = 0 |
| volatile uint8_t Counter1KHz |
| volatile uint8_t DmaEnableRequest = 1 |
| void* pTim0 |
| volatile uint8_t Saw_Up |
| volatile uint8_t slot_10ms = false |
| uint32_t SPIData[5] |
| volatile uint8_t Sync_Timer02 |
| unsigned char TestBldcOff |
| unsigned char TestBldcOn = 0 |
| volatile uint8_t TestBldcUpdtSpdReq = 0 |
| volatile uint16_t TestBldcUpdtSpdTimer = 1000 |
| volatile uint32_t TIM0_PER |
| volatile unsigned short TimerOut1s = 100 |