We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.
#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 usDelay(rrD_100us);//100us Put_Comm_Bit02();//Port OnOff usDelay(rrD_100us);//100us Put_Comm_Bit01();//Port OnOff usDelay(rrD_100us);//100us Put_Comm_Bit00();//Port OnOff usDelay(rrD_100us);//100us PortC1_INPUT();//Port Input Control usDelay(rrD_100us);//100us Get_Comm_Bit07();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit06();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit05();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit04();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit03();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit02();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit01();//Port Input usDelay(rrD_100us);//100us Get_Comm_Bit00();//Port Input usDelay(rrD_100us);//100us PortC1_PUSHPull();//Port Output Control Put_Comm_High();//Port OnOff }
In the assembler, this is converted.
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| ;;;5599 Put_Comm_High();//Port OnOff 00514e f7fffffe BL Put_Comm_High ;;;5600 usDelay(rrD_100us);//100us 005152 e00b B |L1.20844| |L1.20820| DCD PCU_D |L1.20824| DCD GPIO_C |L1.20828| DCD PCU_C |L1.20832| DCD Comm_In_Buf |L1.20836| DCD Comm_Out_Buf |L1.20840| DCD uRR0 |L1.20844| 00516c f44f7009 MOV r0,#0x224 005170 49fe LDR r1,|L1.21868| 005172 8008 STRH r0,[r1,#0] 005174 bf00 NOP |L1.20854| 005176 48fd LDR r0,|L1.21868| 005178 8800 LDRH r0,[r0,#0] ; uRR0 00517a 1e40 SUBS r0,r0,#1 00517c 0400 LSLS r0,r0,#16 00517e 0c00 LSRS r0,r0,#16 005180 49fa LDR r1,|L1.21868| 005182 8008 STRH r0,[r1,#0] 005184 d1f7 BNE |L1.20854| ;;;5601 ;;;5602 Put_Comm_Bit07();//Port OnOff 005186 f7fffffe BL Put_Comm_Bit07 ;;;5603 usDelay(rrD_100us);//100us 00518a f44f7009 MOV r0,#0x224 00518e 49f7 LDR r1,|L1.21868| 005190 8008 STRH r0,[r1,#0] 005192 bf00 NOP |L1.20884| 005194 48f5 LDR r0,|L1.21868| 005196 8800 LDRH r0,[r0,#0] ; uRR0 005198 1e40 SUBS r0,r0,#1 00519a 0400 LSLS r0,r0,#16 00519c 0c00 LSRS r0,r0,#16 00519e 49f3 LDR r1,|L1.21868| 0051a0 8008 STRH r0,[r1,#0] 0051a2 d1f7 BNE |L1.20884| ;;;5604 Put_Comm_Bit06();//Port OnOff 0051a4 f7fffffe BL Put_Comm_Bit06 ;;;5605 usDelay(rrD_100us);//100us 0051a8 f44f7009 MOV r0,#0x224 0051ac 49ef LDR r1,|L1.21868| 0051ae 8008 STRH r0,[r1,#0] 0051b0 bf00 NOP |L1.20914| 0051b2 48ee LDR r0,|L1.21868| 0051b4 8800 LDRH r0,[r0,#0] ; uRR0 0051b6 1e40 SUBS r0,r0,#1 0051b8 0400 LSLS r0,r0,#16 0051ba 0c00 LSRS r0,r0,#16 0051bc 49eb LDR r1,|L1.21868| 0051be 8008 STRH r0,[r1,#0] 0051c0 d1f7 BNE |L1.20914| ;;;5606 Put_Comm_Bit05();//Port OnOff 0051c2 f7fffffe BL Put_Comm_Bit05 ;;;5607 usDelay(rrD_100us);//100us 0051c6 f44f7009 MOV r0,#0x224 0051ca 49e8 LDR r1,|L1.21868| 0051cc 8008 STRH r0,[r1,#0] 0051ce bf00 NOP |L1.20944| 0051d0 48e6 LDR r0,|L1.21868| 0051d2 8800 LDRH r0,[r0,#0] ; uRR0 0051d4 1e40 SUBS r0,r0,#1 0051d6 0400 LSLS r0,r0,#16 0051d8 0c00 LSRS r0,r0,#16 0051da 49e4 LDR r1,|L1.21868| 0051dc 8008 STRH r0,[r1,#0] 0051de d1f7 BNE |L1.20944| ;;;5608 Put_Comm_Bit04();//Port OnOff 0051e0 f7fffffe BL Put_Comm_Bit04 ;;;5609 usDelay(rrD_100us);//100us 0051e4 f44f7009 MOV r0,#0x224 0051e8 49e0 LDR r1,|L1.21868| 0051ea 8008 STRH r0,[r1,#0] 0051ec bf00 NOP |L1.20974| 0051ee 48df LDR r0,|L1.21868| 0051f0 8800 LDRH r0,[r0,#0] ; uRR0 0051f2 1e40 SUBS r0,r0,#1 0051f4 0400 LSLS r0,r0,#16 0051f6 0c00 LSRS r0,r0,#16 0051f8 49dc LDR r1,|L1.21868| 0051fa 8008 STRH r0,[r1,#0] 0051fc d1f7 BNE |L1.20974| ;;;5610 Put_Comm_Bit03();//Port OnOff 0051fe f7fffffe BL Put_Comm_Bit03 ;;;5611 usDelay(rrD_100us);//100us 005202 f44f7009 MOV r0,#0x224 005206 49d9 LDR r1,|L1.21868| 005208 8008 STRH r0,[r1,#0] 00520a bf00 NOP |L1.21004| 00520c 48d7 LDR r0,|L1.21868| 00520e 8800 LDRH r0,[r0,#0] ; uRR0 005210 1e40 SUBS r0,r0,#1 005212 0400 LSLS r0,r0,#16 005214 0c00 LSRS r0,r0,#16 005216 49d5 LDR r1,|L1.21868| 005218 8008 STRH r0,[r1,#0] 00521a d1f7 BNE |L1.21004| ;;;5612 Put_Comm_Bit02();//Port OnOff 00521c f7fffffe BL Put_Comm_Bit02 ;;;5613 usDelay(rrD_100us);//100us 005220 f44f7009 MOV r0,#0x224 005224 49d1 LDR r1,|L1.21868| 005226 8008 STRH r0,[r1,#0] 005228 bf00 NOP |L1.21034| 00522a 48d0 LDR r0,|L1.21868| 00522c 8800 LDRH r0,[r0,#0] ; uRR0 00522e 1e40 SUBS r0,r0,#1 005230 0400 LSLS r0,r0,#16 005232 0c00 LSRS r0,r0,#16 005234 49cd LDR r1,|L1.21868| 005236 8008 STRH r0,[r1,#0] 005238 d1f7 BNE |L1.21034| ;;;5614 Put_Comm_Bit01();//Port OnOff 00523a f7fffffe BL Put_Comm_Bit01 ;;;5615 usDelay(rrD_100us);//100us 00523e f44f7009 MOV r0,#0x224 005242 49ca LDR r1,|L1.21868| 005244 8008 STRH r0,[r1,#0] 005246 bf00 NOP |L1.21064| 005248 48c8 LDR r0,|L1.21868| 00524a 8800 LDRH r0,[r0,#0] ; uRR0 00524c 1e40 SUBS r0,r0,#1 00524e 0400 LSLS r0,r0,#16 005250 0c00 LSRS r0,r0,#16 005252 49c6 LDR r1,|L1.21868| 005254 8008 STRH r0,[r1,#0] 005256 d1f7 BNE |L1.21064| ;;;5616 Put_Comm_Bit00();//Port OnOff 005258 f7fffffe BL Put_Comm_Bit00 ;;;5617 usDelay(rrD_100us);//100us 00525c f44f7009 MOV r0,#0x224 005260 49c2 LDR r1,|L1.21868| 005262 8008 STRH r0,[r1,#0] 005264 bf00 NOP |L1.21094| 005266 48c1 LDR r0,|L1.21868| 005268 8800 LDRH r0,[r0,#0] ; uRR0 00526a 1e40 SUBS r0,r0,#1 00526c 0400 LSLS r0,r0,#16 00526e 0c00 LSRS r0,r0,#16 005270 49be LDR r1,|L1.21868| 005272 8008 STRH r0,[r1,#0] 005274 d1f7 BNE |L1.21094| ;;;5618 ;;;5619 PortC1_INPUT();//Port Input Control 005276 f7fffffe BL PortC1_INPUT ;;;5620 usDelay(rrD_100us);//100us 00527a f44f7009 MOV r0,#0x224 00527e 49bb LDR r1,|L1.21868| 005280 8008 STRH r0,[r1,#0] 005282 bf00 NOP |L1.21124| 005284 48b9 LDR r0,|L1.21868| 005286 8800 LDRH r0,[r0,#0] ; uRR0 005288 1e40 SUBS r0,r0,#1 00528a 0400 LSLS r0,r0,#16 00528c 0c00 LSRS r0,r0,#16 00528e 49b7 LDR r1,|L1.21868| 005290 8008 STRH r0,[r1,#0] 005292 d1f7 BNE |L1.21124| ;;;5621 Get_Comm_Bit07();//Port Input 005294 f7fffffe BL Get_Comm_Bit07 ;;;5622 usDelay(rrD_100us);//100us 005298 f44f7009 MOV r0,#0x224 00529c 49b3 LDR r1,|L1.21868| 00529e 8008 STRH r0,[r1,#0] 0052a0 bf00 NOP |L1.21154| 0052a2 48b2 LDR r0,|L1.21868| 0052a4 8800 LDRH r0,[r0,#0] ; uRR0 0052a6 1e40 SUBS r0,r0,#1 0052a8 0400 LSLS r0,r0,#16 0052aa 0c00 LSRS r0,r0,#16 0052ac 49af LDR r1,|L1.21868| 0052ae 8008 STRH r0,[r1,#0] 0052b0 d1f7 BNE |L1.21154| ;;;5623 Get_Comm_Bit06();//Port Input 0052b2 f7fffffe BL Get_Comm_Bit06 ;;;5624 usDelay(rrD_100us);//100us 0052b6 f44f7009 MOV r0,#0x224 0052ba 49ac LDR r1,|L1.21868| 0052bc 8008 STRH r0,[r1,#0] 0052be bf00 NOP |L1.21184| 0052c0 48aa LDR r0,|L1.21868| 0052c2 8800 LDRH r0,[r0,#0] ; uRR0 0052c4 1e40 SUBS r0,r0,#1 0052c6 0400 LSLS r0,r0,#16 0052c8 0c00 LSRS r0,r0,#16 0052ca 49a8 LDR r1,|L1.21868| 0052cc 8008 STRH r0,[r1,#0] 0052ce d1f7 BNE |L1.21184| ;;;5625 Get_Comm_Bit05();//Port Input 0052d0 f7fffffe BL Get_Comm_Bit05 ;;;5626 usDelay(rrD_100us);//100us 0052d4 f44f7009 MOV r0,#0x224 0052d8 49a4 LDR r1,|L1.21868| 0052da 8008 STRH r0,[r1,#0] 0052dc bf00 NOP |L1.21214| 0052de 48a3 LDR r0,|L1.21868| 0052e0 8800 LDRH r0,[r0,#0] ; uRR0 0052e2 1e40 SUBS r0,r0,#1 0052e4 0400 LSLS r0,r0,#16 0052e6 0c00 LSRS r0,r0,#16 0052e8 49a0 LDR r1,|L1.21868| 0052ea 8008 STRH r0,[r1,#0] 0052ec d1f7 BNE |L1.21214| ;;;5627 Get_Comm_Bit04();//Port Input 0052ee f7fffffe BL Get_Comm_Bit04 ;;;5628 usDelay(rrD_100us);//100us 0052f2 f44f7009 MOV r0,#0x224 0052f6 499d LDR r1,|L1.21868| 0052f8 8008 STRH r0,[r1,#0] 0052fa bf00 NOP |L1.21244| 0052fc 489b LDR r0,|L1.21868| 0052fe 8800 LDRH r0,[r0,#0] ; uRR0 005300 1e40 SUBS r0,r0,#1 005302 0400 LSLS r0,r0,#16 005304 0c00 LSRS r0,r0,#16 005306 4999 LDR r1,|L1.21868| 005308 8008 STRH r0,[r1,#0] 00530a d1f7 BNE |L1.21244| ;;;5629 Get_Comm_Bit03();//Port Input 00530c f7fffffe BL Get_Comm_Bit03 ;;;5630 usDelay(rrD_100us);//100us 005310 f44f7009 MOV r0,#0x224 005314 4995 LDR r1,|L1.21868| 005316 8008 STRH r0,[r1,#0] 005318 bf00 NOP |L1.21274| 00531a 4894 LDR r0,|L1.21868| 00531c 8800 LDRH r0,[r0,#0] ; uRR0 00531e 1e40 SUBS r0,r0,#1 005320 0400 LSLS r0,r0,#16 005322 0c00 LSRS r0,r0,#16 005324 4991 LDR r1,|L1.21868| 005326 8008 STRH r0,[r1,#0] 005328 d1f7 BNE |L1.21274| ;;;5631 Get_Comm_Bit02();//Port Input 00532a f7fffffe BL Get_Comm_Bit02 ;;;5632 usDelay(rrD_100us);//100us 00532e f44f7009 MOV r0,#0x224 005332 498e LDR r1,|L1.21868| 005334 8008 STRH r0,[r1,#0] 005336 bf00 NOP |L1.21304| 005338 488c LDR r0,|L1.21868| 00533a 8800 LDRH r0,[r0,#0] ; uRR0 00533c 1e40 SUBS r0,r0,#1 00533e 0400 LSLS r0,r0,#16 005340 0c00 LSRS r0,r0,#16 005342 498a LDR r1,|L1.21868| 005344 8008 STRH r0,[r1,#0] 005346 d1f7 BNE |L1.21304| ;;;5633 Get_Comm_Bit01();//Port Input 005348 f7fffffe BL Get_Comm_Bit01 ;;;5634 usDelay(rrD_100us);//100us 00534c f44f7009 MOV r0,#0x224 005350 4986 LDR r1,|L1.21868| 005352 8008 STRH r0,[r1,#0] 005354 bf00 NOP |L1.21334| 005356 4885 LDR r0,|L1.21868| 005358 8800 LDRH r0,[r0,#0] ; uRR0 00535a 1e40 SUBS r0,r0,#1 00535c 0400 LSLS r0,r0,#16 00535e 0c00 LSRS r0,r0,#16 005360 4982 LDR r1,|L1.21868| 005362 8008 STRH r0,[r1,#0] 005364 d1f7 BNE |L1.21334| ;;;5635 Get_Comm_Bit00();//Port Input 005366 f7fffffe BL Get_Comm_Bit00 ;;;5636 usDelay(rrD_100us);//100us 00536a f44f7009 MOV r0,#0x224 00536e 497f LDR r1,|L1.21868| 005370 8008 STRH r0,[r1,#0] 005372 bf00 NOP |L1.21364| 005374 487d LDR r0,|L1.21868| 005376 8800 LDRH r0,[r0,#0] ; uRR0 005378 1e40 SUBS r0,r0,#1 00537a 0400 LSLS r0,r0,#16 00537c 0c00 LSRS r0,r0,#16 00537e 497b LDR r1,|L1.21868| 005380 8008 STRH r0,[r1,#0] 005382 d1f7 BNE |L1.21364| ;;;5637 ;;;5638 PortC1_PUSHPull();//Port Output Control 005384 f7fffffe BL PortC1_PUSHPull ;;;5639 Put_Comm_High();//Port OnOff 005388 f7fffffe BL Put_Comm_High ;;;5640 ;;;5641 } 00538c bd10 POP {r4,pc} ;;;5642 ENDP
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?
lee dh said:Delay function does not work properly
What, exactly, do you mean by that - in what way(s) does it "not work" ?
http://www.catb.org/esr/faqs/smart-questions.html#code
lee dh said:100us is not implemented properly.
in what way(s), exactly, is it not "proper" ?
lee dh said:because of DCD
What makes you think that's the reason?