![]() | ![]() | ![]() |
| | #31 |
|
I have parallel! Yay ima try to get the money i need tomorrow. Where should i buy it from? Sparkfun is out of stock on USB TINY thing on the parallel and if im buying parallel i might as well make it lol and buy it also ![]() If i buy parallel and board then its about $98 + $7 shipping/handling so that $105 ... I have $90 on me now. I need $15 tomorrow. That shouldnt be a issue at all! Yeah!
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 18th January 2009 at 03:29 AM. | |
| |
| | #32 |
| | |
| |
| | #33 | |
| Quote:
Think I'll dig around in their site and see what else they have... for an upgrade! Ya, that's it! I need an upgrade! Stupid gear lust. Must... Not... Spend... Learn what you already have.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | ||
| |
| | #34 |
|
nice find Pommie(Mike)! The only reason i would still get the other is the RED board lol and also the SD part & 2 serial and looks like the other is mainly LEDs and variable resistors which i have here anyway Cool tho.I like this board alot!: SparkFun Electronics - Development Platform for LPC2378 This looks like it would be a nice upgrade: SparkFun Electronics - Prototyping Board for LPC2294 (1MB)
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 18th January 2009 at 02:33 PM. | |
| |
| | #35 | |
|
Futz i have a feeling that your issue is Compiler specific. I was reading some info on the RealView MDK : Quote:
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | ||
| |
| | #36 |
|
try this as your startup code: Code: /* ***************************************************************************************************************
crt.s STARTUP ASSEMBLY CODE
-----------------------
Module includes the interrupt vectors and start-up code.
*************************************************************************************************************** */
/* Stack Sizes */
.set UND_STACK_SIZE, 0x00000004 /* stack for "undefined instruction" interrupts is 4 bytes */
.set ABT_STACK_SIZE, 0x00000004 /* stack for "abort" interrupts is 4 bytes */
.set FIQ_STACK_SIZE, 0x00000004 /* stack for "FIQ" interrupts is 4 bytes */
.set IRQ_STACK_SIZE, 0X00000004 /* stack for "IRQ" normal interrupts is 4 bytes */
.set SVC_STACK_SIZE, 0x00000004 /* stack for "SVC" supervisor mode is 4 bytes */
#.set _MEMMAP, 0xE01FC040
/* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs (program status registers) */
.set MODE_USR, 0x10 /* Normal User Mode */
.set MODE_FIQ, 0x11 /* FIQ Processing Fast Interrupts Mode */
.set MODE_IRQ, 0x12 /* IRQ Processing Standard Interrupts Mode */
.set MODE_SVC, 0x13 /* Supervisor Processing Software Interrupts Mode */
.set MODE_ABT, 0x17 /* Abort Processing memory Faults Mode */
.set MODE_UND, 0x1B /* Undefined Processing Undefined Instructions Mode */
.set MODE_SYS, 0x1F /* System Running Priviledged Operating System Tasks Mode */
.set I_BIT, 0x80 /* when I bit is set, IRQ is disabled (program status registers) */
.set F_BIT, 0x40 /* when F bit is set, FIQ is disabled (program status registers) */
.text
.arm
.global Reset_Handler
.global _startup
.func _startup
_startup:
# Exception Vectors
_vectors: ldr PC, Reset_Addr
ldr PC, Undef_Addr
ldr PC, SWI_Addr
ldr PC, PAbt_Addr
ldr PC, DAbt_Addr
NOP ; Reserved Vector
LDR PC, IRQ_Addr ; I added this
LDR PC, [PC, #-0x0FF0] ; Vector from VicVectAddr
LDR PC, FIQ_Addr
Reset_Addr: .word Reset_Handler /* defined in this module below */
Undef_Addr: .word UNDEF_Routine /* defined in main.c */
SWI_Addr: .word SWI_Routine /* defined in main.c */
PAbt_Addr: .word UNDEF_Routine /* defined in main.c */
DAbt_Addr: .word UNDEF_Routine /* defined in main.c */
IRQ_Addr: .word IRQ_Routine /* defined in main.c */
FIQ_Addr: .word FIQ_Routine /* defined in main.c */
.word 0 /* rounds the vectors and ISR addresses to 64 bytes total */
Reset_Handler:
/* Setup a stack for each mode - note that this only sets up a usable stack
for User mode. Also each mode is setup with interrupts initially disabled. */
ldr r0, =_stack_end
msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode */
mov sp, r0
sub r0, r0, #UND_STACK_SIZE
msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */
mov sp, r0
sub r0, r0, #ABT_STACK_SIZE
msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */
mov sp, r0
sub r0, r0, #FIQ_STACK_SIZE
msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */
mov sp, r0
sub r0, r0, #IRQ_STACK_SIZE
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
mov sp, r0
sub r0, r0, #SVC_STACK_SIZE
msr CPSR_c, #MODE_SYS|I_BIT|F_BIT /* User Mode */
mov sp, r0
/* copy .data section (Copy from ROM to RAM) */
ldr R1, =_etext
ldr R2, =_data
ldr R3, =_edata
1: cmp R2, R3
ldrlo R0, [R1], #4
strlo R0, [R2], #4
blo 1b
/* Clear .bss section (Zero init) */
mov R0, #0
ldr R1, =_bss_start
ldr R2, =_bss_end
2: cmp R1, R2
strlo R0, [R1], #4
blo 2b
/* Enter the C code */
b main
.endfunc
.end
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #37 | ||
| Quote:
And I say, "Huh? Why? That seems crazy! Ok, whatever... Lets get em enabled then"Quote:
To enable interrupts you add a piece of code like this (tho this one might not be for 2148). Code: /* Enable and disable functions "ripped" from a sample by R O Software.
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact. */
#include "VIClowlevel.h"
#define IRQ_MASK 0x00000080
static inline unsigned asm_get_cpsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ );
return retval;
}
static inline void asm_set_cpsr(unsigned val)
{
asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
}
unsigned enableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}
unsigned disableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr | IRQ_MASK);
return _cpsr;
}
unsigned restoreIRQ(unsigned oldCPSR)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
return _cpsr;
}
/* end of R O code */
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 18th January 2009 at 08:25 PM. | |||
| |
| | #38 |
|
look at this startup script (from RealView(MDK)). I added the txt extension so i can upload it.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 18th January 2009 at 08:56 PM. | |
| |
| | #39 |
|
well I don't know where it went, but the one thing that jumped out at me was that once it is an interrupt function the compiler should take interrupt controller if it has the support built in for the hardware so you should check the generated code for releasing the interrupt twice. If not it is better to put it in a function call to handle the end of interrupt functionality so you only have to do it once. I also do not remember now if you cleared the interrupt in the timer, this also needs to be done for it to trigger again. If the processor itself has stopped running you need to check and see if it is in one of the error interrupt endless loops. While the standard compiler code defaults to this it would be a good idea to through out some indication that it has landed there if you are not going to handle them so you know it is time to reboot, or to let you know why it did if you have the watchdog running. Dan | |
| |
| | #40 | ||||
| Quote:
![]() Quote:
Code: void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr = 0; //end of interrupt - dummy write
}
Quote:
Quote:
Code: void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
manton (Mike) over at the SparkFun forum thread about this says the whole thing is because crt.s disables interrupts (for some whacked out reason that I can't comprehend). Here's the lines that do it (as far as I can see): Code: .set I_BIT, 0x80 /* when I bit is set, IRQ is disabled (program status registers) */ .set F_BIT, 0x40 /* when F bit is set, FIQ is disabled (program status registers) */ ... msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */ mov sp, r0 sub r0, r0, #FIQ_STACK_SIZE msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */ mov sp, r0 sub r0, r0, #IRQ_STACK_SIZE The thing I don't get is why they think it's normal to have interrupts disabled in the startup code. That seems completely nutz to me. What good is an MCU with the interrupts disabled? It's crippled, IMHO. But whatever, if I can use that other piece of code to enable them then fine.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 21st January 2009 at 03:54 PM. | |||||
| |
| | #41 |
|
all interrupts on a PIC are disabled until you enable them. I wish i had that board so i could help ya out but me just thinking and reading isnt helping much Why not just comment this out: Code: .set I_BIT, 0x80 /* when I bit is set, IRQ is disabled (program status registers) */
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #42 | |
| I realize that. But all you have to do is diddle bits in a couple registers and they work. In this thing they're disabled. I diddle all the right registers and they should work, but they don't because somebody thought it made sense to make sure they couldn't work without doing something that should have already been done in the startup code. Weird! Quote:
Code: msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */
mov sp, r0
sub r0, r0, #IRQ_STACK_SIZE
Code: msr CPSR_c, #MODE_IRQ /* IRQ Mode */
mov sp, r0
sub r0, r0, #IRQ_STACK_SIZE
EDIT: Well, that doesn't work. I'm obviously completely misunderstanding something. And none of the tutorials or other people's source code I've looked at mentions it. For the life of me I can't understand why someone thought that was a good idea. I'm sure there's some good reason, but I sure don't know what it might be.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 19th January 2009 at 07:32 PM. | ||
| |
| | #43 |
|
This code pops the interrupt once each time the processor is reset, but never again. So I'm getting closer... Code: #include "LPC214x.h"
#define PLOCK 0x400
#define IRQ_MASK 0x00000080
void init(void);
void IRQ_Routine (void) __attribute__ ((interrupt("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
unsigned enableIRQ(void);
unsigned disableIRQ(void);
unsigned restoreIRQ(unsigned oldCPSR);
unsigned int cp;
int main(void)
{
int i;
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0TCR = 0x02; //reset counter
T0IR = 0xff;
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x0000ffff; //compare-hit count
VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:
VICVectAddr0 = (unsigned)&IRQ_Routine; //set interrupt vector in 0
VICIntEnable = 0x00000010; //enable TIMER0 interrupt
T0TCR = 0x01; //enable Timer0
cp = enableIRQ();
while(1){
i=0;
i=1;
}
}
void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0; //end of interrupt - dummy write
}
void init(void)
{
PLLCFG=0x24; //set multiplier/divider values
PLLFEED=0xaa;
PLLFEED=0x55;
PLLCON=0x01; //enable PLL
PLLFEED=0xaa;
PLLFEED=0x55;
while(!(PLLSTAT & PLOCK)); //wait for the PLL to lock to set frequency
PLLCON=0x3; //connect the PLL as the clock source
PLLFEED=0xaa;
PLLFEED=0x55;
MAMCR=0x02; //enable MAM
MAMTIM=0x04; //set number of clocks for flash memory fetch
VPBDIV=0x01; //set peripheral clock(pclk) to system clock(cclk)
}
void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
static inline unsigned asm_get_cpsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ );
return retval;
}
static inline void asm_set_cpsr(unsigned val)
{
asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
}
unsigned enableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}
unsigned disableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr | IRQ_MASK);
return _cpsr;
}
unsigned restoreIRQ(unsigned oldCPSR)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
return _cpsr;
}
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #44 |
|
i think its: Code: void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0; //end of interrupt - dummy write
//The above bold changes the address again
}
Code: void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr = 0x0000; //end of interrupt - dummy write
}
5.4.12 Vector Address register (VICVectAddr - 0xFFFF F030)
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #45 |
| Oops! But that didn't fix it. Still doesn't work. Now, for no apparent reason, the debugger has decided it doesn't want to run the program anymore. Stupid thing.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 19th January 2009 at 08:21 PM. | |
| |
|
| Tags |
| interrupts, lpc2148, match, timer, work |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| LPC2148 async serial baud rate confusion | futz | Micro Controllers | 23 | 30th December 2008 03:48 PM |
| Best way for homemade E-Match | SMUGangsta | Chit-Chat | 8 | 2nd November 2008 09:43 PM |
| Two circuits ground do not match | xtcx | Electronic Projects Design/Ideas/Reviews | 3 | 24th December 2007 09:03 AM |
| I don't know why my Periodic ON-OFF Timer don't work. They are two CD4541. | taotoon | Electronic Projects Design/Ideas/Reviews | 7 | 29th October 2007 03:10 AM |
| Need Help in Timer Interrupts, CCS C and PIC16F628A | mysemcon2000 | Micro Controllers | 0 | 4th November 2006 02:12 PM |