| Electronic Components Datasheet Search |
|
AN2618 Datasheet(PDF) 19 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2618 Datasheet(HTML) 19 Page - STMicroelectronics |
|
19 / 23 page ![]() AN2618 Code example 6.utility.c 19/23 /******************************************************************************** * FUNCTION: mc_etpu_chan_init * * PURPOSE: This function initialize the eTPU channel including * * 1. Assign the eTPU function to channel * * 2. Configure the channel * * 3. Calculate and auto assign function frame * ********************************************************************************/ uint16_t mc_etpu_chan_init(uint8_t channel, uint8_t function, uint8_t mode, \ uint8_t num_param, uint32_t config, uint16_t func_frame) { if (func_frame == 0) { func_frame = mc_etpu_malloc(num_param); if (func_frame == 0) return((uint16_t)ETPU_ERROR_MALLOC); } ETPU.CHAN[channel].CR.R = config + (function<<16) + (func_frame>>3); ETPU.CHAN[channel].SCR.R = mode; return(func_frame); } /******************************************************************************** * FUNCTION: mc_etpu_malloc * * PURPOSE: This function calculates the memory space for a eTPU function based * * the number and size of the parameter as well as the static local * * variable for a eTPU function. The function returns the address at * * which the next function frame can be assigned. * ********************************************************************************/ uint16_t mc_etpu_malloc(uint16_t num_params) { static uint16_t etpu_pram_used = ETPU_PRAM_START_ADDR; uint16_t next_function_frame = etpu_pram_used; //each parameter takes 4 bytes, check if there is enough space available if ((etpu_pram_used + num_params<<2) > ETPU_PRAM_SIZE) return(0); else etpu_pram_used += (num_params<<2); //Scale the pointer for the function frame return (next_function_frame); } |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |