Skip to content

Commit 0c703b3

Browse files
committed
Move timer ISR handlers and PWM handler into RAM (fix #819)
1 parent 0873ae2 commit 0c703b3

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

cores/esp8266/core_esp8266_timer.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/*
1+
/*
22
timer.c - Timer1 library for esp8266
33
44
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
55
This file is part of the esp8266 core for Arduino environment.
6-
6+
77
This library is free software; you can redistribute it and/or
88
modify it under the terms of the GNU Lesser General Public
99
License as published by the Free Software Foundation; either
@@ -29,13 +29,13 @@
2929

3030
static volatile timercallback timer1_user_cb = NULL;
3131

32-
void timer1_isr_handler(void *para){
32+
void ICACHE_RAM_ATTR timer1_isr_handler(void *para){
3333
if ((T1C & ((1 << TCAR) | (1 << TCIT))) == 0) TEIE &= ~TEIE1;//edge int disable
3434
T1I = 0;
3535
if (timer1_user_cb) {
3636
// to make ISR compatible to Arduino AVR model where interrupts are disabled
3737
// we disable them before we call the client ISR
38-
uint32_t savedPS = xt_rsil(15); // stop other interrupts
38+
uint32_t savedPS = xt_rsil(15); // stop other interrupts
3939
timer1_user_cb();
4040
xt_wsr_ps(savedPS);
4141
}
@@ -61,7 +61,7 @@ void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload){
6161
T1I = 0;
6262
}
6363

64-
void timer1_write(uint32_t ticks){
64+
void ICACHE_RAM_ATTR timer1_write(uint32_t ticks){
6565
T1L = ((ticks)& 0x7FFFFF);
6666
if ((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable
6767
}
@@ -76,7 +76,7 @@ void timer1_disable(){
7676

7777
static volatile timercallback timer0_user_cb = NULL;
7878

79-
void timer0_isr_handler(void* para){
79+
void ICACHE_RAM_ATTR timer0_isr_handler(void* para){
8080
if (timer0_user_cb) {
8181
// to make ISR compatible to Arduino AVR model where interrupts are disabled
8282
// we disable them before we call the client ISR
@@ -99,6 +99,3 @@ void timer0_detachInterrupt() {
9999
timer0_user_cb = NULL;
100100
ETS_CCOMPARE0_DISABLE();
101101
}
102-
103-
104-

cores/esp8266/core_esp8266_wiring_pwm.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/*
1+
/*
22
pwm.c - analogWrite implementation for esp8266
33
44
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
55
This file is part of the esp8266 core for Arduino environment.
6-
6+
77
This library is free software; you can redistribute it and/or
88
modify it under the terms of the GNU Lesser General Public
99
License as published by the Free Software Foundation; either
@@ -88,7 +88,7 @@ void prep_pwm_steps(){
8888
ETS_FRC1_INTR_ENABLE();
8989
}
9090

91-
void pwm_timer_isr(){
91+
void ICACHE_RAM_ATTR pwm_timer_isr(){
9292
static uint8_t current_step = 0;
9393
static uint8_t stepcount = 0;
9494
static uint16_t steps[17];

0 commit comments

Comments
 (0)