#include <LPC21xx.H>
void T0isr(void) __irq;
volatile int i=0;
volatile int num=0;
int main(void)
{
IODIR0 = 0XFFFFFFFF;
T0IR = 1;
T0CCR = 0;
T0PR = 12000;
T0MR0 = 4;
T0MCR = 3;
T0TCR = 1;
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable |= 0x00000010; //Enable the interrupt
}
void T0isr(void) __irq
{
T0IR = 1;
if(++i==100){
IO0SET = 0x00000001;
i=0;
}
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 void T0isr(void) __irq { if(++i==100) { IO0PIN ^= 0x00000001; i=0; } T0IR = 1; /* Clear MAT0.0 interrupt flag */ VICVectAddr = 0; /* Acknowledge Interrupt */ }
PLLCFG = 0x00000024; // Set multiplier and divider of PLL to give 60.00 Mhz
PLLCON = 0x00000001; // Enable the PLL
PLLFEED = 0x000000AA; // Update PLL registers with feed sequence
PLLFEED = 0x00000055;
while (!(PLLSTAT & 0x00000400)) // test Lock bit
{
;
}
PLLCON = 0x00000003; // Connect the PLL
PLLFEED = 0x000000AA; //Update PLL registers
PLLFEED = 0x00000055;
VPBDIV = 0x00000002;
#include <LPC21xx.H>
void T0isr(void) __irq;
volatile int i=0;
volatile int num=0;
int main(void)
{
IODIR0 = 0XFFFFFFFF;
T0IR = 1;
T0CCR = 0;
T0PR = 12000;
T0MR0 = 4;
T0MCR = 3;
T0TCR = 1;
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable |= 0x00000010; //Enable the interrupt
[COLOR="#FF0000"]while(1){};[/COLOR] //Add SuperLoop
}
void T0isr(void) __irq
{
T0IR = 1;
if(++i==100){
IO0SET = 0x00000001;
i=0;
}
}
#include <LPC21xx.H>
void T0isr(void)__irq;
volatile int i=0;
volatile int sayi=0;
int main(void)
{
VPBDIV= 0X00000002;
T0TC=0x00000005;
T0PR=15;
T0MCR=0x00000006;
T0MR0=150;
T0EMR=0x0031;
T0TCR=0x01;
IODIR1 = 0X00000000;
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable |= 0x00000010; //Enable the interrupt
}
void T0isr(void) __irq
{
T0IR = 1; /* Clear MAT0.0 interrupt flag */
VICVectAddr = 0; /* Acknowledge Interrupt */
}
The final version of my code is below and works but when i will add SuperLoops code it doesnt work.
With this code i can toggle MAT0.0 pin by changing the T0PR and T0MR0, but i couldnt achieve the 500ms toggle action.
// Fosc = 12MHz
// CCLK = 60MHz
// PCLK = CCLK/4 = 15MHz
#include <LPC21xx.H>
__irq void T0isr(void);
unsigned long i=0; // Dummy Count Variable for SuperLoop
int main(void)
{
IODIR0 = 0XFFFFFFFF;
T0MR0 = 7500000L; // Set Timer Duration to .5 Seconds (500ms) TimerDuration * PCLK = .5 * 15MHz = 7500000
T0PR = 0; // Set Timer Prescaler to None
T0MCR = 3; // Interrupt and Reset on Counts
T0TCR = 1; // Timer0 Enabled
VICVectAddr4 = (unsigned long)T0isr; // Set Timer ISR Vector Address
VICVectCntl4 = 0x00000024; //Assign Interrupt Vector to Timer0
VICIntEnable = 0x00000010; //Enable Timer0 Interrupt
while(1){i++;}; // SuperLoop to Keep Execution in main()
}
__irq void T0isr(void) // Timer0 ISR
{
IO0PIN ^= 0x00000001; // Toggle P0.0 Output
T0IR = 1; // Clear Interrupt Flag
VICVectAddr = 0; // Acknowledge Interrupt
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?