Skip to content

Commit 3953cb4

Browse files
committed
fixed PWM outputs not working after digitalWrite()
1 parent 22fd331 commit 3953cb4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

sam/1.0.3/cores/arduino/wiring_analog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void TC_SetCMR_ChannelB(Tc *tc, uint32_t chan, uint32_t v)
191191
}
192192

193193
static uint8_t PWMEnabled = 0;
194-
static uint8_t pinEnabled[PINS_COUNT];
194+
/*static*/ uint8_t pinEnabled[PINS_COUNT];
195195
static uint8_t TCChanEnabled[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
196196

197197
void analogOutputInit(void) {

sam/1.0.3/cores/arduino/wiring_digital.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
extern "C" {
2323
#endif
2424

25+
extern uint8_t pinEnabled[PINS_COUNT];
26+
2527
extern void pinMode( uint32_t ulPin, uint32_t ulMode )
2628
{
2729
if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN )
@@ -39,6 +41,7 @@ extern void pinMode( uint32_t ulPin, uint32_t ulMode )
3941
PIO_INPUT,
4042
g_APinDescription[ulPin].ulPin,
4143
0 ) ;
44+
pinEnabled[ulPin] = 0;
4245
break ;
4346

4447
case INPUT_PULLUP:
@@ -49,6 +52,7 @@ extern void pinMode( uint32_t ulPin, uint32_t ulMode )
4952
PIO_INPUT,
5053
g_APinDescription[ulPin].ulPin,
5154
PIO_PULLUP ) ;
55+
pinEnabled[ulPin] = 0;
5256
break ;
5357

5458
case OUTPUT:
@@ -57,6 +61,7 @@ extern void pinMode( uint32_t ulPin, uint32_t ulMode )
5761
PIO_OUTPUT_1,
5862
g_APinDescription[ulPin].ulPin,
5963
g_APinDescription[ulPin].ulPinConfiguration ) ;
64+
pinEnabled[ulPin] = 0;
6065

6166
/* if all pins are output, disable PIO Controller clocking, reduce power consumption */
6267
if ( g_APinDescription[ulPin].pPort->PIO_OSR == 0xffffffff )

0 commit comments

Comments
 (0)