Synchronising timer output and assembly code
2005-10-15 by conhalk
Hello, I am using the lpc2138 and i read an external port while a timer and the PWM output two waveforms like this timer: _ _ _ _ _| |_| |_| |_| |_| pwm: _ _ _| |_____| |_____| this code section is written in assembly, and timer and pwm are reset as shown below so that the waveforms and code can be PERFECTELY SYNCHRONIZED. The problem is that in the simulator, each time i pass through this section they all get synchronized differently, while on the real board the symptoms (intermittent operation) indicate the same (my scope doesn't work so I can't be sure). Could it be so? If my code is wrong, does a way to synchronise timer output, pwm output and assembly code execution exist? Karl Olsen pointed out an issue about the simulator not knowing about waitstates in my previous question. Could this apply here as well? CODE: // R5 is address of T1TCR MOV R4,#0x00000000 ADD R4,R4,#0XE0000000 ADD R4,R4,#0X00008000 ADD R4,R4,#0X00000004 // R2 is address of PWMTCR MOV R2,#0x00000000 ADD R2,R2,#0XE0000000 ADD R2,R2,#0X00014000 ADD R2,R2,#0X00000004 // reset PWM MOV R7, #11 STRB R7,[R2] MOV R7, #9 STRB R7,[R2] // reset timer MOV R7, #3 STRB R7,[R4] MOV R7, #1 STRB R7,[R4] .. code in assembly that reads in the data