I am trying to run my PWM program on keil for lpc2148. This has 10% duty cycle. However, I can see the signal on Port0 (P0.21). Here is my code. I am quite confident it is right.
#include<lpc214x.h>
int main()
{
PINSEL0=0x00000000; // P0.0 to P0.15 pins of PORT0 as GPIO
PINSEL1=0x00000400; // P0.21 Pin of PORT0 as PWM
PINSEL2=0x00000000; // P1.16 to P1.31 pins of PORT1 as GPIO
/*Configure the PLL block and set the CCLK and PCLK at 60 MHz */
PLL0CON=0x01;
PLL0CFG=0x24;
PLL0FEED=0xaa;
PLL0FEED=0x55;
while (!(PLL0STAT & 0x00000400));
PLL0CON=0x03;
PLL0FEED=0xaa;
PLL0FEED=0x55;
VPBDIV=0x01;
/* Setup and initialize the PWM block */
PWMPCR=0x00; // Single Edge PWM Mode
PWMPR=60000-1; // Resolution of PWM is set at 1 mS
PWMMR0=10; // Period of PWM is 10 mS
PWMMR5=1; // Pulse width of PWM5 is 1 mS
PWMMCR= (1<<1); // PWMTC is reset on match with PWMMR0
PWMLER= (1<<5)| (1<<0); // Update Match Registers PWMMR0 and PWMMR5
PWMPCR= (1<<13); // Enable PWM5 output
PWMTCR= (1<<1); // Reset PWM TC and PWM PR
PWMTCR= (1<<0)| (1<<3); // Enable PWM Timer Counters and PWM Mode
//PWMMR5 = 1;
//PWMLER = (1<<5); //Update Latch Enable bit for PWMMR5
}

The Keil debugger's "logic analyser" tool watches specific global variables via SWO trace. Your code has no global variables and you have not stated what you are monitoring.
On real hardware only global variables can be monitored. Peripheral registers and I/O pins can only be monitored in simulation as specified at https://www.keil.com/support/man/docs/uv4/uv4_db_dbg_logicanalyzer_restrictions.htm
To get a trace that follows your PWM, you will need to implement a PWM interrupt handler that either copies the state of the output pin to a global, or (better) reads the
PWMIRregister and copies that to a global variable and/or sets the global to the state inferred by thePWMIRregister. Then you monitor the global variable rather than the pin directly.For example:
And you can then monitor
pwmoutand/orpwmmatchin the logic analyser.I am not familiar with your specific microcontroller so the above may need some tweaking. Obviously you will also need to enable the interrupt handler - something like:
but I am just copying existing examples - no guarantees.
Finally at the end of your
main()add an infinite loop to preventmain()from terminating into who knows where: