Reply by conhalk October 14, 20052005-10-14
Hello, I am using the lpc2138 and i read an external port while a
timer and the PWM output two waveforms like this

_ _ _ _
_| |_| |_| |_| |_|

_ _
_| |_____| |_____|

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

Karl Olsen pointed out an issue about the simulator not knowing
about waitstates in my previous question. Could this apply here as


// 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

An Engineer's Guide to the LPC2100 Series