Reply by "sub...@aeolusdevelopment.com" November 3, 20072007-11-03
rabbit1575 Wrote
>To make thing simple, in startup.s, i enter the main() as a USR mode
>with interrupt enabled. Then i commented out the mode changing as
>well as the ChangeIRQ() function in the main. As follows:
>
>Startup.s :
>
>// Enter User mode with interrupt enable
> MSR CPSR_c, #Mode_USR
> MOV SP, R0

I won't have any opportunity to look in detail at actual values until this
evening (someone else may), but the first question I would ask is what is
the value of Mode_USR? Also take a look in the newlib-lpc library for the
interrupt enable/disable code.

>But it still doesn't work this way. Anything else i would need to
>do?. Possible the hardware(IC) flaw?

Unlikely to be a HW fault.

Robert
--------------------------------
mail2web.com - Microsoft Exchange solutions from a leading provider -
http://link.mail2web.com/Business/Exchange



An Engineer's Guide to the LPC2100 Series

Reply by Robert Adsett November 3, 20072007-11-03
At 09:42 PM 11/2/2007 +0000, rabbit1575 wrote:
>Mode_SVC EQU 0x13
>Mode_USR EQU 0x10
>
>These are the values for Supersivory and User Mode.

You should probably be in system mode rather than user mode but you do seem
to have interrupts enabled. I've not had an opportunity to look at the rest
of your code.

>I will take a look at the newlib as suggested.

You might want to take a look at the VIC code while you are there.

>I am wondering why there is no standard way of doing this.

Not worked with embedded micros for long have we? :)

The standard way, such as exists is to run in system mode and
enable/disable interrupts as needed. There is a fair amount of example
code out there.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
Reply by rabbit1575 November 2, 20072007-11-02
Mode_SVC EQU 0x13
Mode_USR EQU 0x10

These are the values for Supersivory and User Mode.
I will take a look at the newlib as suggested.
I am wondering why there is no standard way of doing this.
--- In l..., "subscriptions@..."
wrote:
>
> rabbit1575 Wrote
> >To make thing simple, in startup.s, i enter the main() as a USR
mode
> >with interrupt enabled. Then i commented out the mode changing
as
> >well as the ChangeIRQ() function in the main. As follows:
> >
> >Startup.s :
> >
> >// Enter User mode with interrupt enable
> > MSR CPSR_c, #Mode_USR
> > MOV SP, R0
>
> I won't have any opportunity to look in detail at actual values
until this
> evening (someone else may), but the first question I would ask is
what is
> the value of Mode_USR? Also take a look in the newlib-lpc library
for the
> interrupt enable/disable code.
>
>
>
> >But it still doesn't work this way. Anything else i would need to
> >do?. Possible the hardware(IC) flaw?
>
> Unlikely to be a HW fault.
>
> Robert
>
>
> -------------------------------
-
> mail2web.com - Microsoft Exchange solutions from a leading
provider -
> http://link.mail2web.com/Business/Exchange
>



Reply by rabbit1575 November 2, 20072007-11-02
I am currently in SYS mode when entering main(). Here is the
snippets of my Startup.s :

// Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size

// Enter System Mode
MSR CPSR_c, #Mode_SYS
MOV SP, R0
// Enter the C code
LDR R0,=?C?INIT
TST R0,#1 ; Bit-0 set: INIT is Thumb
LDREQ LR,=exit?A ; ARM Mode
LDRNE LR,=exit?T ; Thumb Mode
BX R0
ENDP

It doesn't work. Something wrong here?

> >int main (void)
> >{
> > IODIR0 = 0x880; //set P0.7 and P0.11 as output
> > IOSET0 = 0x880; //turn off LED
> > IOCLR0 = 0x880; //turn on LED at those 2 ports
> >
> > T0_init(); //setup timer
> >
> > __asm {MSR CPSR_c, #0x13} //Go into Supervisor Mode
>
> What mode are you in? If you are in user mode this won't work.
If you are
> in system mode it won't help.
>
> Since really the only thing user mode blocks is enable/disable of
> interrupts IMO there is seldom any reason to be in user mode and
you should
> start in system mode.
>
> Robert
Reply by "sub...@aeolusdevelopment.com" November 2, 20072007-11-02
rabbit1575 Wrote
>I am currently in SYS mode when entering main(). Here is the
>snippets of my Startup.s :
>
>// Enter Supervisor Mode and set its Stack Pointer
> MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
> MOV SP, R0
> SUB R0, R0, #SVC_Stack_Size
>
>// Enter System Mode
> MSR CPSR_c, #Mode_SYS
> MOV SP, R0
>// Enter the C code
> LDR R0,=?C?INIT
> TST R0,#1 ; Bit-0 set: INIT is Thumb
> LDREQ LR,=exit?A ; ARM Mode
> LDRNE LR,=exit?T ; Thumb Mode
> BX R0
> ENDP
>
>It doesn't work. Something wrong here?

I don't see anything off the top of my head. Your entering supervisor mode
before setting interrupt enable rather struck me and you almost certainly
do not want to do that. It is probably not the cause of your problem
though.

Check your interrupt enable code. As I recall the interrupt bits in the
micro's mode register must be set to zero to enable interrupts (but I may
be confusing it with a different micro). Verify the values in the code and
documentation.

Robert

--------------------------------
mail2web.com Enhanced email for the mobile individual based on Microsoft
Exchange - http://link.mail2web.com/Personal/EnhancedEmail



Reply by "sub...@aeolusdevelopment.com" November 2, 20072007-11-02
rabbit1575 Wrote
>
>I bought ET-ARM LPC2119 Stamp from Futurelec with the development
>board earlier. Really nice actually.
>I have been doing/following all the examples provided by Keil with
>no problem except things that has interrupt associated with it.
>I tried to demonstrate the usage of Timer0 but i failed to get the
>interrupt fires. Looks like something wrong somewhere. I ran out
>of idea already now. I have been foolowing all the advise from all
>forums available on the Net but still failed to get it work.
>
>Simulation in Keil works just fine. But unfortunately real hardware
>target doesn't work. I used the standard Startup.s provided by Keil
>with some modification on the PLLCFG only to suit the on-board's
>crystal frequency.
>
>Hopefully someone could shed some light here. I have been
>scratching my head for almost a month without success.
>#pragma ARM // use ARM mode
>void ChangeIRQ (unsigned int NewState) /*__arm*/ {
>//int my_cpsr; //
>
> __asm {
> AND R0,R0,#0 // clear R0 (used for 'my_cpsr')
> MRS R0,CPSR // my_cpsr, CPSR
> ORR R0,R0,#0x80; // my_cpsr, my_cpsr,#0x80
>
> LDAV R1,R10,NewState // load parameter-value 'NewState' into R1
> BIC R0,R0,R1,LSL #7 // my_cpsr, my_cpsr, NewState, LSL #7
> MSR CPSR_c, R0 // CPSR_c,my_cpsr
> }
>}
>int main (void)
>{
> IODIR0 = 0x880; //set P0.7 and P0.11 as output
> IOSET0 = 0x880; //turn off LED
> IOCLR0 = 0x880; //turn on LED at those 2 ports
>
> T0_init(); //setup timer
>
> __asm {MSR CPSR_c, #0x13} //Go into Supervisor Mode

What mode are you in? If you are in user mode this won't work. If you are
in system mode it won't help.

Since really the only thing user mode blocks is enable/disable of
interrupts IMO there is seldom any reason to be in user mode and you should
start in system mode.

Robert
--------------------------------
mail2web LIVE Free email based on Microsoft Exchange technology -
http://link.mail2web.com/LIVE



Reply by rabbit1575 November 2, 20072007-11-02
Hi,

I bought ET-ARM LPC2119 Stamp from Futurelec with the development
board earlier. Really nice actually.
I have been doing/following all the examples provided by Keil with
no problem except things that has interrupt associated with it.
I tried to demonstrate the usage of Timer0 but i failed to get the
interrupt fires. Looks like something wrong somewhere. I ran out
of idea already now. I have been foolowing all the advise from all
forums available on the Net but still failed to get it work.

Simulation in Keil works just fine. But unfortunately real hardware
target doesn't work. I used the standard Startup.s provided by Keil
with some modification on the PLLCFG only to suit the on-board's
crystal frequency.

Hopefully someone could shed some light here. I have been
scratching my head for almost a month without success.

#include // Philips Peripheral Registers

void T0_init(void);
void Timer_HandlerISR(void) __irq;
static int CurrentTime=0;

void Timer_HandlerISR(void) __irq // interrupt handler
{
CurrentTime++;
if (CurrentTime > 100)
{
IOSET0 = 0x880; // turn off LED P0.7 and P0.11
}

T0IR = 0x01; // Clear interrupt flag by writing
1 to Bit 0
VICVectAddr = 0x00000000; // Acknowledge Interrupt
(rough?)
}

void T0_init(void)
{

VICVectAddr0 = (unsigned long) Timer_HandlerISR; // set
interrupt vector in 0
VICVectCntl0 = 0x00000024; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // enable interrupt Timer 0

T0MR0 = ((19660800*3)/(1000/10))-1; // Compare-hit at 10mSec
(-1 reset "tick")
T0MCR = 0x03; // interrupt on match, reset on match
T0TCR = 0x01; // start the timer

}
#pragma ARM // use ARM mode
void ChangeIRQ (unsigned int NewState) /*__arm*/ {
//int my_cpsr; //

__asm {
AND R0,R0,#0 // clear R0 (used for 'my_cpsr')
MRS R0,CPSR // my_cpsr, CPSR
ORR R0,R0,#0x80; // my_cpsr, my_cpsr,#0x80

LDAV R1,R10,NewState // load parameter-value 'NewState' into
R1
BIC R0,R0,R1,LSL #7 // my_cpsr, my_cpsr, NewState, LSL #7
MSR CPSR_c, R0 // CPSR_c,my_cpsr
}
}
int main (void)
{
IODIR0 = 0x880; //set P0.7 and P0.11 as output
IOSET0 = 0x880; //turn off LED
IOCLR0 = 0x880; //turn on LED at those 2 ports

T0_init(); //setup timer

__asm {MSR CPSR_c, #0x13} //Go into Supervisor Mode
ChangeIRQ (1); //1 - Enable , 0- Disable

while(1); //looping

return 0; //never reached
}

Thanks.