реклама на сайте
подробности

 
 
> Обработка прерываний под FreeRTOS, Процессор AT91SAM7X256, компилятор IAR
Igor_F
сообщение Feb 7 2008, 08:19
Сообщение #1





Группа: Новичок
Сообщений: 5
Регистрация: 18-12-07
Пользователь №: 33 392



Помогите, пожалуйста, разобраться.

Работаем с процессором AT91SAM7X256, компилятор IAR.
Есть два обработчика IRQ. Первый из них:


//////////////////////////////////////////
IRQ_Handler_Entry:

;-------------------------
;- Manage Exception Entry
;-------------------------
;- Adjust and save LR_irq in IRQ stack
sub lr, lr, #4
stmfd sp!, {lr}

;- Save r0 and SPSR (need to be saved for nested interrupt)
mrs r14, SPSR
stmfd sp!, {r0,r14}

;- Write in the IVR to support Protect Mode
;- No effect in Normal Mode
;- De-assert the NIRQ and clear the source in Protect Mode
ldr r14, =AT91C_BASE_AIC
ldr r0 , [r14, #AIC_IVR]
str r14, [r14, #AIC_IVR]

;- Enable Interrupt and Switch in Supervisor Mode
msr CPSR_c, #ARM_MODE_SVC

;- Save scratch/used registers and LR in User Stack
stmfd sp!, { r1-r3, r12, r14}

;----------------------------------------------
;- Branch to the routine pointed by the AIC_IVR
;----------------------------------------------
mov r14, pc
bx r0

;----------------------------------------------
;- Manage Exception Exit
;----------------------------------------------
;- Restore scratch/used registers and LR from User Stack
ldmia sp!, { r1-r3, r12, r14}

;- Disable Interrupt and switch back in IRQ mode
msr CPSR_c, #I_BIT | ARM_MODE_IRQ

;- Mark the End of Interrupt on the AIC
ldr r14, =AT91C_BASE_AIC
str r14, [r14, #AIC_EOICR]

;- Restore SPSR_irq and r0 from IRQ stack
ldmia sp!, {r0,r14}
msr SPSR_cxsf, r14

;- Restore adjusted LR_irq from IRQ stack directly in the PC
ldmia sp!, {pc}^
///////////////////////////////////////////


И второй, который вызывается по следующей команде:

LDR PC, [PC, #-0xF20] ; Jump directly to the address given by the AIC

Вот этот обработчик:

vPortPreemptiveTick:
portSAVE_CONTEXT ; Save the context of the current task.

LDR R0, =vTaskIncrementTick ; Increment the tick count - this may wake a task.
mov lr, pc
BX R0
LDR R0, =vTaskSwitchContext ; Select the next task to execute.
mov lr, pc
BX R0

LDR R14, =AT91C_BASE_PITC ; Clear the PIT interrupt
LDR R0, [R14, #PITC_PIVR ]

LDR R14, =AT91C_BASE_AIC ; Mark the End of Interrupt on the AIC
STR R14, [R14, #AIC_EOICR]

portRESTORE_CONTEXT ; Restore the context of the selected task.


При этом первый из них нормально обрабатывает прерывания USART-а, но при переключении между задачами программа вылетает в исключение Data Abort.

При использовании второго обработчика переключение между задачами происходит корректно, но другие прерывания (USART, таймеры) не работают (тоже происходит исключение Data Abort).

Подскажите, как можно объединить два эти обработчика.

И, если не трудно, оставьте ссылку на data sheet с описанием ассемблера AT91SAM7X256.
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 24th June 2025 - 18:45
Рейтинг@Mail.ru


Страница сгенерированна за 0.01357 секунд с 7
ELECTRONIX ©2004-2016