| Electronic Components Datasheet Search |
|
AN2618 Datasheet(PDF) 18 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2618 Datasheet(HTML) 18 Page - STMicroelectronics |
|
18 / 23 page ![]() Code example 6.utility.c AN2618 18/23 Appendix F Code example 6.utility.c /******************************************************************************** * FUNCTION: mc_etpu_init * * PURPOSE: This function initialize the eTPU module including * * 1. Initialize global registers * * 2. Load eTPU code into memory * * 3. Copy initial values of global variables to data RAM * ********************************************************************************/ uint32_t mc_etpu_init(struct etpu_config_t p_etpu_config, uint32_t *code,uint8_t codesize, uint32_t *globals) { uint32_t *code_end; uint32_t unused_code_ram; unused_code_ram = (((ETPU.MCR.B.SCMSIZE - 1 ) * 1024) - (uint32_t)codesize*1024); if ( unused_code_ram < 0 ) return((uint32_t)ETPU_ERROR_CODESIZE); /* 1. Initialize global registers */ ETPU.MISCCMPR.R = p_etpu_config.misc; //write MISC value before it is enable in MCR ETPU.MCR.R = p_etpu_config.mcr; /* Configure Engine 1 */ ETPU.TBCR_1.R = p_etpu_config.tbcr_1; ETPU.STACR_1.R = p_etpu_config.stacr_1; ETPU.ECR_1.R = p_etpu_config.ecr_1; /* Configure Engine 2 */ ETPU.TBCR_2.R = p_etpu_config.tbcr_2; ETPU.STACR_2.R = p_etpu_config.stacr_2; ETPU.ECR_2.R = p_etpu_config.ecr_2; /* load microcode */ /* In order to write the eTPU code ram, both eTPU engine has to be stopped. */ /* Stopping eTPU engine can be achieved by set low power stop bit. */ ETPU.ECR_1.B.MDIS = 1; ETPU.ECR_2.B.MDIS = 1; /* enable writing to SCM */ ETPU.MCR.B.VIS = 1; /* 2. Copy microcode */ mc_memcpy32( &CODE_RAM, code, (uint32_t)codesize*1024); /* disable writing to SCM */ ETPU.MCR.B.VIS = 0; /* 3. Copy initial global values to parameter RAM. */ mc_memcpy32 ( &DATA_RAM, globals, ETPU_GLOBAL_MEM_SIZE); /* After writing the eTPU code ram, both eTPU engine has to be re-started. */ /* Restart eTPU engine can be achieved by clear low power stop bit. */ ETPU.ECR_1.B.MDIS = 0; ETPU.ECR_2.B.MDIS = 0; return((uint32_t) 0); } |
|
|
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 |