Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] ARM LPC2148 basic problems

Status
Not open for further replies.

embpic

Advanced Member level 3
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
Writing to the IOPIN register stores the value in the port output register, bypassing the
need to use both the IOSET and IOCLR registers to obtain the entire written value. This
feature should be used carefully in an application since it affects the entire port.

Also
8.5.3Writing to IOSET/IOCLR .vs. IOPIN
Write to the IOSET/IOCLR register allows easy change of the port’s selected output pin(s)
to high/low level at a time. Only pin/bit(s) in the IOSET/IOCLR written with 1 will be set to
high/low level, while those written as 0 will remain unaffected. However, by just writing to
either IOSET or IOCLR register it is not possible to instantaneously output arbitrary binary
data containing mixture of 0s and 1s on a GPIO port.
Write to the IOPIN register enables instantaneous output of a desired content on the
parallel GPIO. Binary data written into the IOPIN register will affect all output configured
pins of that parallel port: 0s in the IOPIN will produce low level pin outputs and 1s in IOPIN
will produce high level pin outputs. In order to change output of only a group of port’s pins,
application must logically AND readout from the IOPIN with mask containing 0s in bits
corresponding to pins that will be changed, and 1s for all others. Finally, this result has to
be logically ORred with the desired content and stored back into the IOPIN register.
Example 2 from above illustrates output of 0xA5 on PORT0 pins 15 to 8 while preserving
all other PORT0 output pins as they were before.

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)
 
  • Like
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top