1263 views|0 replies

3836

Posts

19

Resources
The OP
 

C6455 CSL_EMIF example [Copy link]

EMFIA examples in CSL
CSL contains at least one example for each peripheral to help developers quickly master its usage.

Initialize and open EMFIA.
There are two functions in the Emifa_ReadWrite_example.c file. There is only one line of code in the main function.

CSL_FINST(((CSL_DevRegs*)CSL_DEV_REGS)->PERCFG1, DEV_PERCFG1_EMIFACTL, \

ENABLE);

It takes some time to understand this sentence, but we know that what it does is to configure PERCFG1 to turn on the EMIFA peripheral (PERCFG1 (Peripheral Configuration Register 1) The Peripheral Configuration Register (PERCFG1) is used to enable the EMIFA and DDR2 Memory Controller. For general peripherals, we need to write a specific UNLOCK value to PERLOCK before turning it on, but for DDR2 and EMIFA, they can be turned on directly. For detailed explanations, please refer to the corresponding documents). After turning on EMIFA, the main function directly calls the emifaReadWrite() function.

In emifaReadWrite(),

The first function called is CSL_emifaInit(NULL). As can be seen from the above explanation, this function is optional. After checking its source code, you will find that it does nothing but simply returns a CSL_OK.

The second function called is

hEmifa = CSL_emifaOpen(&emifaObj, CSL_EMIFA, NULL, &status);

Its function prototype is

CSL_EmifaHandle CSL_emifaOpen (

CSL_EmifaObj *hEmifaObj,

CSL_InstNum emifaNum,

CSL_EmifaParam *pEmifaParam,

CSL_Status *status

);

This function must be looked at in detail. Its first parameter is of type CSL_EmifaObj*, which actually has two fields.

typedef struct CSL_EmifaObj {

/* This is a pointer to the registers of the instance of EMIFA

* referred to by this object

*/

CSL_EmifaRegsOvly regs;

/** This is the instance of EMIFA being referred to by this object */

CSL_InstNum byNum;

} CSL_EmifaObj;

CSL_EmifaRegsOvly contains all the registers of the EMIF module, and CSL_InstNum indicates which EMIF module this is (there is only one EMIF module in C6455, so this value can only be 0).

CSL_EMIFA is a macro whose actual value is

/** @brief Peripheral Instance for EMIFA */

#define CSL_EMIFA (0)

This means there is only one EMIF module.

The third parameter is reserved for later use

typedef struct {

/** Bit mask to be used for module specific parameters. The below

* declaration is just a place-holder for future implementation. Passed as

* an argument to CSL_emifaOpen().

*/

CSL_BitMask16 flags;

} CSL_EmifaParam;

So always pass in NULL.

The fourth parameter is CSL_Status*, which is actually used as both an input and output parameter.

When this function is running, it first checks whether status is NULL. If it is NULL, it returns a NULL to hEmifa, so we must ensure that the value passed in is not NULL. If we always pass in the value returned by CSL_emifaInit(NULL), this condition is always met, so we first call the CSL_emifaInit(NULL) function and then call CSL_emifaOpen.

The return value of this function is a handler, whose actual type is a pointer

/** @brief This is a pointer to @a CSL_EmifaObj and is passed as the first

* parameter to all EMIFA CSL APIs

*/

typedef struct CSL_EmifaObj *CSL_EmifaHandle;

It doesn’t matter if you don’t quite understand it, other API functions will take this handler as their first parameter.

Configure EMIFA hardware
After successfully initializing and opening the hardware, you need to install your own requirements to configure the hardware

status = CSL_emifaHwSetup(hEmifa, &hwSetup);

Mainly look at the two parameters, hwSetup is a variable of CSL_emifaHwSetup. Pay special attention here that the name of this function is CSL_emifaHwSetup, and the type of its parameter is also a pointer to CSL_emifaHwSetup. The definition of CSL_emifaHwSetup is as follows

typedefstruct {

/** Pointer to structure for configuring the Asynchronous Wait Cycle

* Configuration register

*/

CSL_EmifaAsyncWait *asyncWait;

/** Array of CSL_EmifaMemType* for configuring the Chip enables

* as Async or Sync memory type.

*/

CSL_EmifaMemType *ceCfg[NUMCHIPENABLE];

} CSL_EmifaHwSetup;

It should be noted that different peripherals have different definitions of HwSetup type, because this structure is related to hardware (Hw->Hardward). In fact, before calling this function, the various fields of hwSetup have been set to the values we want. I will not copy the corresponding setup code.

This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list