This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
问个关于调用F021函数库的问题,我在HalcoGen上配置了CAN和FEE驱动,移植到CCS6.2新建工程中,现在可以实现CAN的收发,但是在新建一个HSI_EEPROM.c文件中引用头文件,后调用ti_fee.h。然后再主函数中调用函数hsi_eeprom_init();
编译器报错:
F021.h是重复包含了么?
Hi Xuehui,
建议按HALCoGen->Help->Help Topics里的例程介绍进行操作:
This is an example which descibes the steps to use TI-Fee Driver for simple Write Sync, Write Async, Read, Invalidate and Full Format of EEPROM bank.
Step 1:
Create a new project.
Navigate: -> File -> New -> Project -> TMS570xx / RMx
Step 2:
Configure driver code generation:
Navigate: -> TMS570xx / RMx -> Driver Enable
Step 3:
Navigate: -> TMS570xx / RMx -> TI-FEE
Configure FEE settings ( Leave Default for below Example)
Step 4:
Navigate: -> File -> Generate Code
Step 5:
Copy source code below into your application.
Step 6:
Add F021 Library files to CCS Project
The example file example_TI_Fee_Write_Read.c can also be found in the examples folder: ../HALCoGen/examples
/* (c) Texas Instruments 2009-2015, All rights reserved. */ /* * Copyright (C) 2009-2015 Texas Instruments Incorporated - www.ti.com * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* USER CODE BEGIN (0) */ #include "ti_fee.h" /* USER CODE END */ /* Include Files */ #include "sys_common.h" /* USER CODE BEGIN (1) */ uint16 u16JobResult,Status; Std_ReturnType oResult=E_OK; unsigned char read_data[100]={0}; uint8 SpecialRamBlock[100]; unsigned char pattern; uint16 u16writecounter; unsigned int FeeVirtualSectorNumber; unsigned char VsState, u8EEPIndex; unsigned char u8VirtualSector; uint8 Test_Recovery; uint8 Test_Cancel; void delay(void) { unsigned int dummycnt=0x0000FFU; do { dummycnt--; } while(dummycnt>0); } /* USER CODE END */ /* USER CODE BEGIN (2) */ /* USER CODE END */ void main(void) { /* USER CODE BEGIN (3) */ unsigned int BlockNumber; unsigned int BlockOffset, Length; unsigned char *Read_Ptr=read_data; unsigned int loop; /* Initialize RAM array.*/ for(loop=0;loop<100;loop++)SpecialRamBlock[loop] = loop; /* Initialize FEE. This will create Virtual sectors, initialize global variables etc.*/ TI_Fee_Init(); do { TI_Fee_MainFunction(); delay(); Status=TI_Fee_GetStatus(0 ); } while(Status!= IDLE); /* Write the block into EEP Asynchronously. Block size is configured in ti_fee_cfg.c file. Default Block size is 8 bytes */ BlockNumber=0x1; TI_Fee_WriteAsync(BlockNumber, &SpecialRamBlock[0]); do { TI_Fee_MainFunction(); delay(); Status=TI_Fee_GetStatus(0); } while(Status!=IDLE); /* Write the block into EEP Synchronously. Write will not happen since data is same. */ TI_Fee_WriteSync(BlockNumber, &SpecialRamBlock[0]); /* Read the block with unknown length */ BlockOffset = 0; Length = 0xFFFF; oResult=TI_Fee_Read(BlockNumber,BlockOffset,Read_Ptr,Length); do { TI_Fee_MainFunction(); delay(); Status=TI_Fee_GetStatus(0); } while(Status!=IDLE); /* Invalidate a written block */ TI_Fee_InvalidateBlock(BlockNumber); do { TI_Fee_MainFunction(); delay(); Status=TI_Fee_GetStatus(0); } while(Status!=IDLE); /* Format bank 7 */ TI_Fee_Format(0xA5A5A5A5U); while(1); /* USER CODE END */ } /* USER CODE BEGIN (4) */ /* USER CODE END */
Hi Xuehui,
在按上述步骤配置完后,在新建main()文件时,需注意将HALCoGen自动生成的空的main()文件删除,避免重复。
Hi David :
根据例子我把编写以下几个函数:
Hi Xuehui,
你之前的编译出错的问题搞定了吗?
首先,你有没有看过TI FEE User Guide的文档(如附件)?是否清楚EEPROM的操作机制?另外,看一下你的芯片手册,查一下0xF0200000地址指向哪里。
下图是从TI FEE User Guide截取的虚拟扇区的头的State和Value。你可以在FEE初始化函数后打断点,当初始化完成后,如果0xF0200000为一个扇区的起始地址,且此时该地址的值为0x00000000 0000FFFF,这说明当前扇区为激活扇区,接下来FEE操作即在该扇区进行。
另外,提供一个基于TMS570LS0432的FEE例程,仅供参考。该例程在TI_Fee_Init();后打断点,浏览Memory的结果如下,并非所有区域均为FF,前面的0x00000000 0000FFFF即为虚拟扇区的头: