[SOLVED] ARM LPC2148 basic problems

Status
Not open for further replies.

embpic

Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Visit site
Activity points
5,213
Hello masters
i just have started with ARM7 TDMI processor. n i successfully done led blinking.but i am facing problem to toggle the led.when i was blink led but using IOxSET and IOxCLR but i want to use toggle pin as we do in PIC and 8051 programming.
 

You cannot do that like you do in 8051 or PIC because that's the difference in their architecture.
Instead you can write your own little routine like this:
Code:
void toggle_P0_LED0(void) {
      if(IOPIN0 & 0x01) IOCLR0   =  0x01;
      else                   IOSET0  =  0x01;
}
 

but i want to use toggle pin as we do in PIC and 8051 programming.

I wonder if you refer to

Also

Source:
 
thanx but if i change IOPIN then will it affect on port. that is IOSET & IOCLR
 

Yes it will affect all bits of the port but since you want to toggle a bit just use EXCLUSIVE OR and you can change only a single bit.

Code:
IOPIN ^= 0x1;   // this will toggle bit 0 
IOPIN ^= 0x2;   // this will toggle bit 1
IOPIN ^= 0x4;   // this will toggle bit 2
.....
 

ok means my code will like this
Code:
int main(void)
{
	VPBDIV = 0x00000000;
	PINSEL0 = 0x00000000;
	PINSEL1 = 0x00000000;
	PINSEL2 = 0x00000000;
	IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16);
	IO1CLR = (1<<19);
	while(1)
	{
		IO1PIN ^= (1<<19);
		delay(100);
		IO1PIN ^= (1<<19);
		delay(100);
	}
}

void delay(unsigned int del)
{
	unsigned int i,j;
	for(i=0;i<del;i++)
		for(j=0;j<60000;j++);
}

will it work?
actually i can't check right now i am out of station.
thanx.

- - - Updated - - -

in above code i have toggle one LED.
 
Last edited:

will it work?
actually i can't check right now i am out of station.
thanx.

- - - Updated - - -

in above code i have toggle one LED.

Yes, this should work fine but either place delay before main or add the delay prototype before main
 

again i tried last time timer interrupt.
is timer is auto-reload when interrupt occur?
and it enter only ones in ISR.
and my code

Code:
#include<lpc214x.h>

#define LED1_ON() IO1SET=(1<<16)
#define LED2_ON() IO1SET=(1<<17)
#define LED3_ON() IO1SET=(1<<18)
#define LED4_ON() IO1SET=(1<<19)

#define LED1_OFF() IO1CLR=(1<<16)
#define LED2_OFF() IO1CLR=(1<<17)
#define LED3_OFF() IO1CLR=(1<<18)
#define LED4_OFF() IO1CLR=(1<<19)

void timer0(void)__irq;
void init_timer0(void);
void Initialize(void);

int main(void)
{
	Initialize();
	while(1);
}

void Initialize(void)
{
	VPBDIV = 0x00;
	IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16);		// Set P1.16, P1.17, P1.18, P1.19 as Output
	IO1CLR = (1<<19);
	init_timer0();	
}

void init_timer0(void)
{
	T0IR = 0xff;
	T0TC = 0x00;
	T0PR = 0x00000020;
	T0PC = 0x00;
	T0MR0 = 0x0000900;
	T0MCR = 0x0001;
	T0TCR = 0x02;
	VICIntEnable = 0x00000010;
	VICIntSelect = 0x00000000;
	VICVectCntl0 = 0x00000024;
	VICVectAddr0 = (unsigned long)timer0;
	T0TCR = 0x01;
}

void timer0(void)__irq
{
	T0IR = 0xff;
	IO1PIN ^=(1<<19);
}

how to handle interrupt
 

thanxz for interrupt problem.
but
timers are in ARM are not auo-reload. so, do we need to re-initialize it in ISR? or there is other option for that.

- - - Updated - - -

thanxz for interrupt problem.
but
timers are in ARM are not auo-reload. so, do we need to re-initialize it in ISR? or there is other option for that.

- - - Updated - - -

thanxz for interrupt problem.
but
timers are in ARM are not auo-reload. so, do we need to re-initialize it in ISR? or there is other option for that.
 

There are several options with the timers, you can reload a new value or use reset on match (T0MCR bit 1)
 
Reactions: embpic

    embpic

    Points: 2
    Helpful Answer Positive Rating
ok thanx do you have any examples on arm processors interrupt's from basic to usb. how to use handler for exceptions and for interrupts. Orr if any video tutorials are there then provide link.
 

Any one have circuit diagram of ARM7 lpc2148 tdmi-s. right now i have development board but i cant do any adjustment in it and even i am also just starting studing ARM. so upload any schematic.
 

actually i have got development kit from friend so no more details i have.
 

thanx alexan_e for giving me option and interrupt for timer also working and giving link for schematic.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…