2138 + Interrupção

Software e Hardware para linha ARM

Moderadores: 51, guest2003, Renie, gpenga

2138 + Interrupção

Mensagempor lrfad2 » 13 Nov 2006 16:10

Alguem já mexeu com isso no lpc2138? Para ser mais específico, a princípio eu teria que gerar uma interrupção quando estourasse o timer0.
Bem... ele eu consegui fazer o timer rodar agora a int não.
Qq ajuda é bem-vinda.
Obrigado
Avatar do usuário
lrfad2
Byte
 
Mensagens: 152
Registrado em: 19 Out 2006 17:35
Localização: São Paulo

Mensagempor gibim » 13 Nov 2006 21:14

Várias coisas terá que fazer

1º - Inicializar o timer. Mas antes lembre-se de inicializar corretamente a PLL e o MAM. Crie um arquivo chamado interrupt.c e coloque e modifique esse código pras suas necessidades.

void InitTimer(void)
{
/*--- Channel 0 registers ---*/
T0IR = 0xFF; // reset match and capture event interrupts
T0TC = 0; // Clear timer counter
T0PR = 0; // No Prescalar
}

2º - Depois inicialize a Interrupção.

void InitVectors()
{
/* Preliminary setup of the VIC. Assign all interrupt chanels to IRQ */
VICIntSelect = 0; // Set all VIC interrupts to IRQ for now
VICIntEnClr = 0xFFFFFFFF; // Diasable all interrupts
VICSoftIntClr = 0xFFFFFFFF; // Clear all software interrutps
VICProtection = 0; // VIC registers can be accessed in User or
VICDefVectAddr = 0; // Clear address of the default ISR
VICVectAddr = 0; // Clear interrupt


/* Clear the VICVectAddress slots 0-15 and VICVectCtrl slots 0-15 */
VICVectAddr0 = \
VICVectAddr1 = \
VICVectAddr2 = \
VICVectAddr3 = \
VICVectAddr4 = \
VICVectAddr5 = \
VICVectAddr6 = \
VICVectAddr7 = \
VICVectAddr8 = \
VICVectAddr9 = \
VICVectAddr10 = \
VICVectAddr11 = \
VICVectAddr12 = \
VICVectAddr13 = \
VICVectAddr14 = \
VICVectAddr15 = 0;

VICVectCntl0 = \ // Disable all vectored IRQ slots
VICVectCntl1 = \
VICVectCntl2 = \
VICVectCntl3 = \
VICVectCntl4 = \
VICVectCntl5 = \
VICVectCntl6 = \
VICVectCntl7 = \
VICVectCntl8 = \
VICVectCntl9 = \
VICVectCntl10 = \
VICVectCntl11 = \
VICVectCntl12 = \
VICVectCntl13 = \
VICVectCntl14 = \
VICVectCntl15 = 0;


/* This section installs the specific interrupts and configure the VIC control registers and sets them as IRQs */

VICProtection = 0; // Accesss VIC in USR | PROTECT
VICDefVectAddr = (unsigned long) NonVectISR; // Install default ISR addr


/* Setup Timer 0: Periodic Interrupt @ DATA_FREQ rate */
T0MR0 = OVERFLOW_TIMER0-1; /* Timer0 Match Value 0 */
T0MCR = 3; /* Interrupt and Reset on MR0 */
T0TCR = 1; /* Timer0 Enable */
VICVectAddr0 = (unsigned long) MM_TIMER0_ISR; /* Set Interrupt Vector in 0 */
VICVectCntl0 = 0x20 | VIC_TIMER0; /* Use it for Timer0 Interrupt */
VICIntEnable |= (1 << VIC_TIMER0); /* Enable Timer0 Interrupt */
}


3º - Agora crie um interrupt.h e coloque isso dentro. Isso no meu caso que estou trabalhando com o KEIL, a declaração de interrupção do IAR é difente.

void NonVectISR() __attribute__ ((interrupt));
void IRQ_Handler() __attribute__ ((interrupt));
void FIQ_Interrupt() __attribute__ ((interrupt));

void MM_RTC_ISR();
void MM_UART0_ISR();
void MM_TIMER0_ISR ();
void InitVectors();


4º - Verifique se seu Startup.s contém corretamente as declarações das chamadas de interrupção. Isso funciona pro uVision da KEIL apenas, no IAR é diferente.

Undef_Handler: B Undef_Handler
SWI_Handler: B SWI_Handler
PAbt_Handler: B PAbt_Handler
DAbt_Handler: B DAbt_Handler
//IRQ_Handler: B IRQ_Handler
//IRQ_Handler: B FIQ_Handler

5º - Agora declare as chamadas que de erro de interrupção e FIQ dentro de um arquivo chamado interrupt.c


/*************************************************************************
*
* Vetor de interrupções
*
************************************************************************/
void FIQ_Interrupt() /* __fiq */
{
VICVectAddr = 0; // Clear interrupt in VIC
while (1)
{
// DEBUG: WE SHOULD NEVER GET HERE
}
}

/*************************************************************************
*
*
************************************************************************/
void NonVectISR()
{
VICVectAddr = 0xFFFFFFFF; // Acknowledge Interrupt
while (1)
{
// DEBUG: WE SHOULD NEVER GET HERE
}
}


6º - Dentro ainda do Interrupt.c o código mínimo para a chamada de interrupção ficaria:
/*************************************************************************
*
*
************************************************************************/
void MM_TIMER1_ISR()
{
T1IR = 1; // Clear timer interrupt
VICVectAddr = 0xFFFFFFFF; // Acknowledge Interrupt
}



Está pronto... Isso funciona.

Se precisar pro IAR diga que eu codo e escrevo aqui. No livro do Fábio Pereira tem tudo para o IAR.

Caso não tenha o livro, poderá comprar, mas também poderá fazer o download dos source code dele a partir do site da editora Érica.

Falow
Avatar do usuário
gibim
Byte
 
Mensagens: 117
Registrado em: 08 Nov 2006 21:40
Localização: Londrina - PR

Mensagempor gibim » 13 Nov 2006 21:41

Pro IAR galera é parecido... Só as diretrizes do compilador são diferente.


Vamos lá... É embaçado tbm, mas com calma conseguimos fazer tudo.

1º - Criar 4 arquivos
A - Interrupt.c
B - Interrupt.h

C - Timer.c
D - Timer.h


2º - Vamos começar pelo mais complicado.
No arquivo já existente cStartup.s79 confirmar se está correto esse trecho de código:

MODULE ?RESET
COMMON INTVEC:CODE:NOROOT(2)
PUBLIC __program_start
EXTERN ?cstartup
EXTERN FIQ_Interrupt
EXTERN IRQ_Handler

; EXTERN undef_handler, swi_handler, prefetch_handler
; EXTERN data_handler, irq_handler, fiq_handler

(...
...
...)

org 0x20
dc32 ?cstartup
org 0x24
dc32 __undef_handler
org 0x28
dc32 __swi_handler
org 0x2c
dc32 __prefetch_handler
org 0x30
dc32 __data_handler
org 0x38
dc32 IRQ_Handler
org 0x3c
dc32 FIQ_Interrupt
LTORG


3º - Agora no arquivo Interrupt.c monte as funções de interrupção:

void NonVectISR(void)
{
while(TRUE); // Se chegar aqui seu programa está com super paus!
}


void InitVectors(void)
{
/* Preliminary setup of the VIC. Assign all interrupt chanels to IRQ */
VICIntSelect = 0; // Set all VIC interrupts to IRQ for now
VICIntEnClear = 0xFFFFFFFF; // Diasable all interrupts
VICSoftIntClear = 0xFFFFFFFF; // Clear all software interrutps
VICProtection = 0; // VIC registers can be accessed in User or
// privileged mode
VICVectAddr = 0; // Clear interrupt
VICDefVectAddr = 0; // Clear address of the default ISR


/* Clear the VICVectAddress slots 0-15 and VICVectCtrl slots 0-15 */
VICVectAddr0 = \
VICVectAddr1 = \
VICVectAddr2 = \
VICVectAddr3 = \
VICVectAddr4 = \
VICVectAddr5 = \
VICVectAddr6 = \
VICVectAddr7 = \
VICVectAddr8 = \
VICVectAddr9 = \
VICVectAddr10 = \
VICVectAddr11 = \
VICVectAddr12 = \
VICVectAddr13 = \
VICVectAddr14 = \
VICVectAddr15 = 0;

// Disable all vectored IRQ slots
VICVectCntl0 = \
VICVectCntl1 = \
VICVectCntl2 = \
VICVectCntl3 = \
VICVectCntl4 = \
VICVectCntl5 = \
VICVectCntl6 = \
VICVectCntl7 = \
VICVectCntl8 = \
VICVectCntl9 = \
VICVectCntl10 = \
VICVectCntl11 = \
VICVectCntl12 = \
VICVectCntl13 = \
VICVectCntl14 = \
VICVectCntl15 = 0;


/* This section installs the specific interrupts and configure the VIC
control registers and sets them as IRQs */
VICProtection = 0; // Accesss VIC in USR | PROTECT
VICDefVectAddr = (unsigned int)&NonVectISR; // Install default ISR addr




// Setup the Timer0 interrupt on match interrupt
VICIntSelect &= ~(1<<VIC_TIMER0); // Timer 0 intrpt is an IRQ
VICVectAddr0 = (unsigned int)&MM_TIMER0_ISR; // Install ISR in VIC addr slot
VICVectCntl0 = 0x20 | VIC_TIMER0; // IRQ type, TIMER 0 int enabled
VICIntEnable |= (1<<VIC_TIMER0); // Turn on Timer0 Interrupt

}


/*************************************************************************
* Função: Interrupão IRQ Timer
*
* Description: Interrupções a ciclos periódicos de xx ms.
*
* Código mínimo para desvio danterrupção da interrupção.
************************************************************************/
__irq __arm void IRQ_Handler (void)
{
void (*interrupt_function)();
unsigned int vector;
vector = VICVectAddr; // Get interrupt vector.

interrupt_function = (void(*)())vector; // Call MM_TIMER0_ISR thru pointer
(*interrupt_function)(); // Call vectored interrupt function
VICVectAddr = 0; // Clear interrupt in VIC
}


4º - No arquivo Interrupt.h declare as chamadas:

void NonVectISR(void);
void InitVectors(void);

5º - No arquivo Timer.c monte a rotina de interrupção, este é um código mínimo de piscar um led a cada 200ms, lemre-se de configuar o MAM e a PLL corretamente, no meu caso a 60Mhz e MAM=3:

void MM_TIMER0_ISR(void)
{
static word us_count;

// Contador de tempo universal para o sistema.
TimerCounter0 += OVERFLOW_TIMER0;

us_count++;

// Inverte o Led2 a cada 200ms
if(us_count == 100)
{
us_count = 0;
if (IO0PIN_bit.P0_18 != 0)
LED1_OFF();
else
LED1_ON();
}

T0IR = 1; // Clear timer interrupt
}

void InitTimer(void)
{
/* Init Peripherial divider Pckl = Clk/4 */

/*--- Channel 0 registers ---*/
T0IR = 0xFF; // reset match and capture event interrupts
T0TC = 0; // Clear timer counter
T0PR = 0; // No Prescalar
T0MR0 = OVERFLOW_TIMER0; // Count up to 36,864 for 100Hz interrupt, period = 10ms
T0MCR = 3; // Reset Timer Counter & Interrupt on match
T0TCR = 1; // Counting enable

}

6º - No arquivo Timer.h coloque as declarações de chamada:

void InitTimer(void);
void MM_TIMER0_ISR(void);


Isso funciona corretamente, caso tenha esquecido algo ou encontre alguma dificudado... É só falar galera.

T+
Avatar do usuário
gibim
Byte
 
Mensagens: 117
Registrado em: 08 Nov 2006 21:40
Localização: Londrina - PR

Mensagempor gibim » 13 Nov 2006 21:46

Só mais um detalhe, não existe um vetor fixo que o processador desvia quando ocorre uma interrupção. E sim um módulo aonde você configura quais interrupções podem ser geradas, e então carrega nos registradores "VICVectAddr0" o ponteiro da função que será chamado quando a determinada interrupção ocorrer, porque no "VICVectCntl0", você informa que aquele ponteiro corresponde ao Timer por exemplo.

É meio complicadinho mesmo... Mas usando um pouco de bom senso e leitura dos manuais, vc consegue.

Abraços
Avatar do usuário
gibim
Byte
 
Mensagens: 117
Registrado em: 08 Nov 2006 21:40
Localização: Londrina - PR

Mensagempor lrfad2 » 14 Nov 2006 08:25

1/2 complicado?!?!? é totalmente complicado...rs... Geralmente só de ler o manual eu já consigo fazer as coisas, mas nesse aqui....
Eu vou tentar compliar esse código que vc passou e tentar entender... qq coisa volto a perguntar :)
muito obrigado mesmo
Leandro
Avatar do usuário
lrfad2
Byte
 
Mensagens: 152
Registrado em: 19 Out 2006 17:35
Localização: São Paulo

Mensagempor lrfad2 » 14 Nov 2006 10:58

Bom dia Gibim,
Preciso de alguma literatura que explique como funciona as interrupções + o cStartup.s79, pois ainda não consegui relacionar as informações de cada registrador fornecidas no manual.
Pelo jeito esse livro do Arm7, tem uma abordagem completa sobre interrupções. É isso mesmo?
Ele trata alguma coisa sobre o IAR Embedded Workbench IDE?
Aguardo sua resposta,
Abraços
Leandro
Avatar do usuário
lrfad2
Byte
 
Mensagens: 152
Registrado em: 19 Out 2006 17:35
Localização: São Paulo

Mensagempor gibim » 14 Nov 2006 16:01

Sim, o livro do Fábio é bem completo nisso. Não explica nada sobre o arquivo ...cStartup.s79, pois ele considera as definições dos nomes deste arquivo como padrão.

Faça o seguinte, se você realmente não está entendendo nada sobre as interrupções, pegue esse aquivo de exemplo do site da Olimex, apenas compile e veja rodando.

Crie um break pointe dentro da chamada de interrupção e veja ele periodicamente parando lá.

E no livro do Fábio, você terá o conteúdo dos datashets traduzido. Também ajuda.

Os manuais que você deveria estar lendo para entender como funciona as interrupções são: UM10120_1.pdf e LPC2131_32_34_36_38_2.pdf, encontrado no site da NXP

Gastei um tempinho e montei algo que compila e pisca.
Me manda um email, que eu te envio.

gibim@yahoo.com

Abraços.
Avatar do usuário
gibim
Byte
 
Mensagens: 117
Registrado em: 08 Nov 2006 21:40
Localização: Londrina - PR

Mensagempor Renato » 16 Nov 2006 10:43

Sim, o livro do Fábio é bem completo nisso ...


Não localizei no site Érica o livro ARM do Fábio.
Tá no forno ?
Renato
Byte
 
Mensagens: 224
Registrado em: 20 Out 2006 08:35

Mensagempor gibim » 16 Nov 2006 14:44

OPS!!!, queiram me descupar essa pequena gafe, o livro é do auto: Daniel Rodrigues de Sousa e pode ser localizado pelo site:


http://www.editoraerica.com.br/buscafin ... de%20Sousa

Outra possibilidade é efetuar a compra pelo site da Editora Saber, lá eu paguei mais barato que na própria editora.

http://www.sabermarketing.com.br/sistem ... 2964535484

Obrigado Galera
Avatar do usuário
gibim
Byte
 
Mensagens: 117
Registrado em: 08 Nov 2006 21:40
Localização: Londrina - PR

Mensagempor Fábio Pereira » 16 Nov 2006 17:59

Nossa,

Essa foi feia ...

Eu estava curioso para saber como o Gibim sabia tanto sobre o meu livro se ele ainda nem foi publicado ... Tava até pensando que tinham invadido a minha máquina ... HUAHUAHUAHUA ...

Bom, o meu livro tem uma abordagem bastante profunda sobre o controlador de interrupções dos STR71x (o EIC).

O livro também tem um capítulo sobre os LPC2xxx mas eu ainda não decidi qual a profundidade que abordarei o tema interrupções.

Outra novidade: um capítulo dedicado aos Cortex-M3 :wink:

Até +
Fábio Pereira
embeddedsystems.io
Avatar do usuário
Fábio Pereira
Word
 
Mensagens: 674
Registrado em: 16 Out 2006 09:07
Localização: Kitchener, ON

Mensagempor jean » 16 Nov 2006 18:31

pelo jeito esse livro do FP vai se tornar um best seler "A BÍBLIA DOs ARMs"...hehehehehehehe
Mas tô na fila pra ser um dos primeiros a comprar um...
[]
Jean

"Quem quer fazer alguma coisa, encontra um meio. Quem não quer fazer nada, encontra uma desculpa."
Roberto Shinyashiki
jean
Byte
 
Mensagens: 134
Registrado em: 12 Out 2006 12:03
Localização: Blumenau-SC

Mensagempor lrfad2 » 17 Nov 2006 13:38

Pois é gibim, eu tentei fazer o que vc mencionou mas deu pau. A começar pelo código abaixo. (acusa label duplicado)

org 0x20
dc32 ?cstartup
org 0x24
dc32 __undef_handler
org 0x28
dc32 __swi_handler
org 0x2c
dc32 __prefetch_handler
org 0x30
dc32 __data_handler
org 0x38
dc32 IRQ_Handler
org 0x3c
dc32 FIQ_Interrupt
LTORG

Baseado no que vc me passou + o datasheet do lpc fiz as seguintes rotinas. Vc puder apontar aonde estou errando, eu agradeço.
A situação é a seguinte: O timer esta contanto e resetando quando atinge o valor de T0MR0, mas quando ele reseta deveria gerar uma interrupção, coisa que não esta acontecendo

Configuração do Timer:
void InitTimer0 (void)
{
T0TCR = T0TCR & 0xFE; //Desliga Timer 0

T0TCR = T0TCR | 0x0002; //Reseta contador do Timer 0
T0TCR = T0TCR & 0xFFFD;

T0CTCR=0x00; //seleciona contador como timer
T0TC=0; //zera contador TC

T0PR = 0x00; //incrementa TC a cada PCLK
T0MCR=0X03; //Interrupção do MR0 - Reset Tc qdo Tc=T0Mr0
T0MR0=0x02FFFFFF;
T0TCR = T0TCR | 0x01; //Liga Timer 0
}

Configuração da interrupção
void InitInterrupt (void)
{
VICIntSelect = 0x00000000; // All interrupts are IRQ
VICVectAddr0 = (unsigned) tmr0_handler; // Hold address where Timer0 IRQ service routine starts
VICVectCntl0 = 0x00000024; // Assign slot 0 (the highest) to timer0 interrupt - local "switch" for interrupt is enable
VICIntEnable = 0x00000010; // Timer0 interrupt is enabled
}

Tratamento da interrupçao
__irq void tmr0_handler( void )
{
T0IR |= 0x00000001; //Clear match 0 interrupt
VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
}//__irq __arm void tmr0_handler( void )

Arquivo de configuração s.79
;-----------------------------------------------------------------------------
; This file contains the startup code used by the ICCARM C compiler.
;
; The modules in this file are included in the libraries, and may be replaced
; by any user-defined modules that define the PUBLIC symbol _program_start or
; a user defined start symbol.
; To override the cstartup defined in the library, simply add your modified
; version to the workbench project.
;
; All code in the modules (except ?RESET) will be placed in the ICODE segment.
;
; $Revision: 1.2 $
;
;-----------------------------------------------------------------------------

;
; Naming covention of labels in this file:
;
; ?xxx - External labels only accessed from assembler.
; __xxx - External labels accessed from or defined in C.
; xxx - Labels local to one module (note: this file contains
; several modules).
; main - The starting point of the user program.
;

;---------------------------------------------------------------
; Macros and definitions for the whole file
;---------------------------------------------------------------

; Mode, correspords to bits 0-5 in CPSR
MODE_BITS DEFINE 0x1F ; Bit mask for mode bits in CPSR
USR_MODE DEFINE 0x10 ; User mode
FIQ_MODE DEFINE 0x11 ; Fast Interrupt Request mode
IRQ_MODE DEFINE 0x12 ; Interrupt Request mode
SVC_MODE DEFINE 0x13 ; Supervisor mode
ABT_MODE DEFINE 0x17 ; Abort mode
UND_MODE DEFINE 0x1B ; Undefined Instruction mode
SYS_MODE DEFINE 0x1F ; System mode


;---------------------------------------------------------------
; ?RESET
; Reset Vector.
; Normally, segment INTVEC is linked at address 0.
; For debugging purposes, INTVEC may be placed at other
; addresses.
; A debugger that honors the entry point will start the
; program in a normal way even if INTVEC is not at address 0.
;---------------------------------------------------------------

MODULE ?RESET
COMMON INTVEC:CODE:NOROOT(2)
PUBLIC __program_start
EXTERN ?cstartup
; EXTERN undef_handler, swi_handler, prefetch_handler
; EXTERN data_handler, fiq_handler
; EXTERN irq_handler
CODE32 ; Always ARM mode after reset
org 0x00
__program_start
ldr pc,=?cstartup ; Absolute jump can reach 4 GByte
; ldr b,?cstartup ; Relative branch allows remap, limited to 32 MByte
org 0x04
undef_handler ldr pc,=undef_handler
org 0x08
swi_handler ldr pc,=swi_handler
org 0x0c
prefetch_handler ldr pc,=prefetch_handler
org 0x10
data_handler ldr pc,=data_handler
org 0x18
irq_handler ldr pc,=irq_handler
org 0x1c
fiq_handler ldr pc,=fiq_handler

; Constant table entries (for ldr pc) will be placed at 0x20
; org 0x20

LTORG
; ENDMOD __program_start
ENDMOD


;---------------------------------------------------------------
; ?CSTARTUP
;---------------------------------------------------------------
MODULE ?CSTARTUP

RSEG IRQ_STACK:DATA(2)
RSEG SVC_STACK:DATA:NOROOT(2)
RSEG CSTACK:DATA(2)
RSEG ICODE:CODE:NOROOT(2)
PUBLIC ?cstartup
EXTERN ?main

; Execution starts here.
; After a reset, the mode is ARM, Supervisor, interrupts disabled.


CODE32
?cstartup

; Add initialization nedded before setup of stackpointers here


; Initialize the stack pointers.
; The pattern below can be used for any of the exception stacks:
; FIQ, IRQ, SVC, ABT, UND, SYS.
; The USR mode uses the same stack as SYS.
; The stack segments must be defined in the linker command file,
; and be declared above.
mrs r0,cpsr ; Original PSR value
bic r0,r0,#MODE_BITS ; Clear the mode bits
orr r0,r0,#IRQ_MODE ; Set IRQ mode bits
msr cpsr_c,r0 ; Change the mode
ldr sp,=SFE(IRQ_STACK) & 0xFFFFFFF8 ; End of IRQ_STACK

bic r0,r0,#MODE_BITS ; Clear the mode bits
orr r0,r0,#SYS_MODE ; Set System mode bits
msr cpsr_c,r0 ; Change the mode
ldr sp,=SFE(CSTACK) & 0xFFFFFFF8 ; End of CSTACK

#ifdef __ARMVFP__
; Enable the VFP coprocessor.
mov r0, #0x40000000 ; Set EN bit in VFP
fmxr fpexc, r0 ; FPEXC, clear others.

; Disable underflow exceptions by setting flush to zero mode.
; For full IEEE 754 underflow compliance this code should be removed
; and the appropriate exception handler installed.
mov r0, #0x01000000 ; Set FZ bit in VFP
fmxr fpscr, r0 ; FPSCR, clear others.
#endif

; Add more initialization here


; Continue to ?main for more IAR specific system startup

ldr r0,=?main
bx r0

LTORG

ENDMOD


END


Arquivo de configuração .xcl
// Generated : 10/27/06 16:28:26
//**********************************************************************
// XLINK template command file to be used with the ICCARM C/C++ Compiler
//
// Usage: xlink -f lnkarm <your_object_file(s)>
// -s <program start label> <C/C++ runtime library>
//
// $Revision: 1.3 $
//
//**********************************************************************

//*************************************************************************
// In this file it is assumed that the system has the following
// memory layout:
//
// Exception vectors [0x000000--0x00001F] RAM or ROM
// ROMSTART--ROMEND [0x008000--0x0FFFFF] ROM (or other non-volatile memory)
// RAMSTART--RAMEND [0x100000--0x7FFFFF] RAM (or other read/write memory)
//
// -------------
// Code segments - may be placed anywhere in memory.
// -------------
//
// INTVEC -- Exception vector table.
// SWITAB -- Software interrupt vector table.
// ICODE -- Startup (cstartup) and exception code.
// DIFUNCT -- Dynamic initialization vectors used by C++.
// CODE -- Compiler generated code.
// CODE_I -- Compiler generated code declared __ramfunc (executes in RAM)
// CODE_ID -- Initializer for CODE_I (ROM).
//
// -------------
// Data segments - may be placed anywhere in memory.
// -------------
//
// CSTACK -- The stack used by C/C++ programs (system and user mode).
// IRQ_STACK -- The stack used by IRQ service routines.
// SVC_STACK -- The stack used in supervisor mode
// (Define other exception stacks as needed for
// FIQ, ABT, UND).
// HEAP -- The heap used by malloc and free in C and new and
// delete in C++.
// INITTAB -- Table containing addresses and sizes of segments that
// need to be initialized at startup (by cstartup).
// CHECKSUM -- The linker places checksum byte(s) in this segment,
// when the -J linker command line option is used.
// DATA_y -- Data objects.
//
// Where _y can be one of:
//
// _AN -- Holds uninitialized located objects, i.e. objects with
// an absolute location given by the @ operator or the
// #pragma location directive. Since these segments
// contain objects which already have a fixed address,
// they should not be mentioned in this linker command
// file.
// _C -- Constants (ROM).
// _I -- Initialized data (RAM).
// _ID -- The original content of _I (copied to _I by cstartup) (ROM).
// _N -- Uninitialized data (RAM).
// _Z -- Zero initialized data (RAM).
//
// Note: Be sure to use end values for the defined address ranges.
// Otherwise, the linker may allocate space outside the
// intended memory range.
//*************************************************************************

//************************************************
// Inform the linker about the CPU family used.
//************************************************

-carm

//*************************************************************************
// Segment placement - General information
//
// All numbers in the segment placement command lines below are interpreted
// as hexadecimal unless they are immediately preceded by a '.', which
// denotes decimal notation.
//
// When specifying the segment placement using the -P instead of the -Z
// option, the linker is free to split each segment into its segment parts
// and randomly place these parts within the given ranges in order to
// achieve a more efficient memory usage. One disadvantage, however, is
// that it is not possible to find the start or end address (using
// the assembler operators .sfb./.sfe.) of a segment which has been split
// and reformed.
//
// When generating an output file which is to be used for programming
// external ROM/Flash devices, the -M linker option is very useful
// (see xlink.pdf for details).
//*************************************************************************


//*************************************************************************
// Read-only segments mapped to ROM.
//*************************************************************************

//************************************************
// Address range for reset and exception
// vectors (INTVEC).
// The vector area is 32 bytes,
// an additional 32 bytes is allocated for the
// constant table used by ldr PC in cstartup.s79.
//************************************************

-Z(CODE)INTVEC=0-3F

//************************************************
// Startup code and exception routines (ICODE).
//************************************************

-Z(CODE)ICODE,DIFUNCT=40-7FFFF
-Z(CODE)SWITAB=40-7FFFF

//************************************************
// Code segments may be placed anywhere.
//************************************************

-Z(CODE)CODE=40-7FFFF

//************************************************
// Original ROM location for __ramfunc code copied
// to and executed from RAM.
//************************************************

-Z(CONST)CODE_ID=40-7FFFF

//************************************************
// Various constants and initializers.
//************************************************

-Z(CONST)INITTAB,DATA_ID,DATA_C=40-7FFFF
-Z(CONST)CHECKSUM=40-7FFFF

//*************************************************************************
// Read/write segments mapped to RAM.
//*************************************************************************

//************************************************
// Data segments.
//************************************************

-Z(DATA)DATA_I,DATA_Z,DATA_N=40000000-40007FFF

//************************************************
// __ramfunc code copied to and executed from RAM.
//************************************************

-Z(DATA)CODE_I=40000000-40007FFF

//************************************************
// ICCARM produces code for __ramfunc functions in
// CODE_I segments. The -Q XLINK command line
// option redirects XLINK to emit the code in the
// CODE_ID segment instead, but to keep symbol and
// debug information associated with the CODE_I
// segment, where the code will execute.
//************************************************

-QCODE_I=CODE_ID

//*************************************************************************
// Stack and heap segments.
//*************************************************************************

-Z(DATA)CSTACK+2000=40000000-40007FFF
-Z(DATA)IRQ_STACK+100=40000000-40007FFF
-Z(DATA)HEAP+4000=40000000-40007FFF

//**********************************************************************
// Output user defined segments
//**********************************************************************



//*************************************************************************
// ELF/DWARF support.
//
// Uncomment the line "-Felf" below to generate ELF/DWARF output.
// Available format specifiers are:
//
// "-yn": Suppress DWARF debug output
// "-yp": Multiple ELF program sections
// "-yas": Format suitable for debuggers from ARM Ltd (also sets -p flag)
//
// "-Felf" and the format specifiers can also be supplied directly as
// command line options, or selected from the Xlink Output tab in the
// IAR Embedded Workbench.
//*************************************************************************

// -Felf
Avatar do usuário
lrfad2
Byte
 
Mensagens: 152
Registrado em: 19 Out 2006 17:35
Localização: São Paulo

Mensagempor gibim » 17 Nov 2006 16:54

Troque todos seus tmr0_handler por -> IRQ_Handler, no arquivo *.s79 de inicialização está declarado que a interrupção por _irq chama "IRQ_Handler", então mude tudo ou mantenha o mesmo nome. Isso é linkado, e vai dar problema de nomes mesmo.

Outra coisa, no seu arquivo *.s79 vc mudou umas coisas... Como a declaração de função externa.

MODULE
COMMON INTVEC:CODE:NOROOT(2)
PUBLIC __program_start
EXTERN ?cstartup
EXTERN FIQ_Interrupt
EXTERN IRQ_Handler

; EXTERN undef_handler, swi_handler, prefetch_handler
; EXTERN data_handler, irq_handler, fiq_handler


tenta rodar esse:

http://www.geocities.com/gibim/ARM_Gibim.zip
Avatar do usuário
gibim
Byte
 
Mensagens: 117
Registrado em: 08 Nov 2006 21:40
Localização: Londrina - PR

Mensagempor lrfad2 » 21 Nov 2006 15:37

Boa Tarde pessoal,
Gibim, boas notícias. Compilei o seu código e deu tudo certo. Entrou na int sem problemas.
Pelo que vi, vc não usa o MakeApp que "mascara" bastante o código. Vou tentar reescrever o meu da mesma maneira. Espero não incomodar mais com ess assunto... :roll: ..rs..

Obrigado mesmo pela dica

Abraço

Leandro
Avatar do usuário
lrfad2
Byte
 
Mensagens: 152
Registrado em: 19 Out 2006 17:35
Localização: São Paulo

Mensagempor Renato » 21 Nov 2006 22:20

Caramba !
Houve um tempo que tudo se resumia num simples
Enable Interrupt, push, pop, ...

Mas como dizia uma velha tia:
Depois que inventaram a máquina de costura, não duvido de mais nada ...
Editado pela última vez por Renato em 04 Fev 2007 14:48, em um total de 1 vez.
Renato
Byte
 
Mensagens: 224
Registrado em: 20 Out 2006 08:35

Próximo

Voltar para ARM

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x