Download SH7268/SH7269 Group Video Display Controller 4 Driver User`s

Transcript
SH7268/SH7269 Group
3.3
VDC4 Driver User’s Manual
Example of User-defined Function within VDC4_CheckClock
When using VDC4_CheckClock, the user-defined wait function is required. Two sample implementation are shown
below.
3.3.1
Compare Match Timer
1
/******************************************************************//**
2
* Function Name : Wait_Msec
3
* @brief
Compare Match Timer (1ch) to Wait a msec
4
* @n
Clock select
5
* @n
Peripheral 0 clock 33.33MHz / 512
6
* @param
[in]_UDWORD wait
: Wait time in msec
7
* @retval
void
8
*********************************************************************/
9
void Wait_Msec( _UDWORD wait )
10
{
11
_UDWORD Compare ;
12
_UWORD Reg ;
13
_UDWORD PushReg ;
14
volatile _UBYTE DummyRead ;
15
16
PushReg = ( _UDWORD )CPG.STBCR7.BYTE & 0x0004ul ;
17
/* Standby control register 7 (STBCR7)
18
b3
-----0-- ; MSTP72 : 0 : Compare match timer enable */
19
CPG.STBCR7.BYTE &= ( _UBYTE )( ~0x0004u ) ;
20
/* Dummy read */
21
DummyRead = CPG.STBCR7.BYTE ;
22
23
/* Compare Match Timer Control/Status Register
24
b7
---- ---- 0--- ---- CMF: Compare Match Flag; clearing
25
b6
---- ---- -0-- ---- CMIE: Compare Match Interrupt Enable;
disabled
26
b1:b0
---- ---- ---- --11 CKS: Clock Select, P0/512
27
*/
28
CMT.CMCSR1.WORD = ( _UWORD )0x0003u ;
29
30
/* 1000usec / 15.36usec = 65.1 */
31
Compare = wait * 66ul ;
32
if( Compare >= 0x00010000ul )
33
{
34
Compare = 0x0000FFFFul ;
35
}
36
/* Compare Match Constant Register */
37
CMT.CMCOR1.WORD = ( _UWORD )Compare ;
38
/* Compare Match Counter */
39
CMT.CMCNT1.WORD = 0 ;
40
/* Compare Match Timer Start Register
41
b1
---- ---- ---- --1- STR1: Count Start 1; started
42
*/
43
CMT.CMSTR.WORD |= ( _UWORD )0x0002u ;
44
45
do
46
{
47
Reg = ( _UWORD )( CMT.CMCSR1.WORD & 0x0080u ) ;
48
}
R01AN0778EJ0100 Rev.1.00
Apr 18, 2013
Page 85 of 105