This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to avoid DCD?

I'm sorry. I don't know why it happened, but... the previous post was deleted. Ask the question again.

//----------------------------------------------------------------------------------------------------------------------------------------

This is a communication function.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define rrD_100us 548
volatile UINT16 uRR0;
#define usDelay(TimeVal) {uRR0=TimeVal; while(--uRR0);}//
void PJ_Comm_Data(void)
{
Put_Comm__Low();//Port OnOff
usDelay(rrD_100us);//100us
Put_Comm_High();//Port OnOff
usDelay(rrD_100us);//100us
Put_Comm_Bit07();//Port OnOff
usDelay(rrD_100us);//100us
Put_Comm_Bit06();//Port OnOff
usDelay(rrD_100us);//100us
Put_Comm_Bit05();//Port OnOff
usDelay(rrD_100us);//100us
Put_Comm_Bit04();//Port OnOff
usDelay(rrD_100us);//100us
Put_Comm_Bit03();//Port OnOff
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In the assembler, this is converted.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
PJ_Comm_Data PROC
;;;5594
;;;5595 void PJ_Comm_Data(void)
00512e b510 PUSH {r4,lr}
;;;5596 {
;;;5597 Put_Comm__Low();//Port OnOff
005130 f7fffffe BL Put_Comm__Low
;;;5598 usDelay(rrD_100us);//100us
005134 f44f7009 MOV r0,#0x224
005138 490b LDR r1,|L1.20840|
00513a 8008 STRH r0,[r1,#0]
00513c bf00 NOP
|L1.20798|
00513e 480a LDR r0,|L1.20840|
005140 8800 LDRH r0,[r0,#0] ; uRR0
005142 1e40 SUBS r0,r0,#1
005144 0400 LSLS r0,r0,#16
005146 0c00 LSRS r0,r0,#16
005148 4907 LDR r1,|L1.20840|
00514a 8008 STRH r0,[r1,#0]
00514c d1f7 BNE |L1.20798|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Delay function does not work properly because of DCD.

I measured 100 us through the port with an oscilloscope. By the way. Because of DCD, 100us is not implemented properly.

Also, whenever I change the code little by little, DCD runs around.

How to avoid DCD?

0