Specifications
SH7670 Group Example of Cache Memory Setting
R01AN0300EJ0101 Rev. 1.01 Page 10 of 12
Oct. 15, 2010
3.3 Sample program list "main.c" (3)
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* ---- Filling SDRAM area ---- */
ptr1 = SDRAM_ADDR_CACHABLE; /* Cache-enabled space */
for(i=0; i<16; i++){ /* Only written to the cache */
*ptr1++ = 0x55; /* in write-back mode */
}
/* ==== Comparing cache-enabled and cache-disabled spaces ==== */
ptr1 = SDRAM_ADDR_CACHABLE; /* Cache-enabled space */
ptr2 = SDRAM_ADDR_NON_CACHABLE; /* Cache-disabled space */
for(i=0; i<16; i++){
if(*ptr1++ == *ptr2++ ){
while(1){
/* Error in cache setting */
}
}
}
while(1){
/* Program end */
}
}
#pragma section CACHE /* Allocated to a non-cacheable area */
/*""FUNC COMMENT""*************************************************************
* ID :
* Outline : Cache setting
*-----------------------------------------------------------------------------
* Include : #include <machine.h>
* : #include "iodefine.h"
*-----------------------------------------------------------------------------
* Declaration : int io_set_cache(unsigned int mode)
*-----------------------------------------------------------------------------
* Function : Cache is placed in the mode specified by the argument "mode".
*-----------------------------------------------------------------------------
* Argument : unsigned int mode : I : Set the value of cache control register 1
*-----------------------------------------------------------------------------
* ReturnValue : 0 : Normally finished
*-----------------------------------------------------------------------------
* Notice : This function must be allocated in the CSO non-cacheable area.
* : Interrupts are disabled during cache operation.
*""FUNC COMMENT END""*********************************************************/
int io_set_cache(unsigned int mode)
{
int mask;
mask = get_imask(); /* ↓↓↓ interrupts disabled ↓↓↓ */
set_imask(15);
/* ==== Setting cache register ==== */
CCNT.CCR1.LONG = mode;
set_imask(mask); /* ↑↑↑ interrupts disabled ↑↑↑ */
return 0;
}
/* End of file */