First, a bit of background. I'm a Mechanical Engineer, and over the past two years I have been working on a project that started originally with an Arduino Uno, and is now currently on a custom board based off of the sam3x8e / Arduino Due platform. I have no formal training in C++ or microcontroller architectures, so I will more than likely use the wrong names for everything and be a bit slow to follow. Please bear with me.
Over the past two months or so, I've been trying to transition entirely away from the Arduino platform (hardware and IDE). For all its merits, it's not enough for what we need, and it has ended up causing a lot of problems for us in the long run. As of right now, everything on our custom board does work, but it's run through the Visual Micro plugin for Atmel Studio, so essentially still on the Arduino IDE.
We've got 13 ADC channels (including chip temp), 4 PWM channels, 2 TC waveform channels, 2 TC capture channels, and a handful of digital I/Os on our board that we need access to.
All are operational except one of the TC waveform channels. PC26 is connected to pin 4 on the Arduino Due, and within the Arduino IDE is considered a PWM channel, but it is actually a TC channel. I ran into a similar problem with PC25, but managed to get it working by following some similar formatting with the TC capture channels. I've tried everything I know how to do to get PC26 up and running the same way, as a PWM channel, but I can't figure it out, and I can't seem to find anything in the Arduino source code that would lead me in the right direction.
I need to set up PC26 the same way that PC25 is setup below. As far as I can tell, they're both a part of TC6. PC25 is TIOA6 and PC26 is TIOB6 - the 'B' seems to be my problem.
This comes from src\ASF\sam\boards\arduino_due_x\arduino_due_x.h -
Code: Select all
/*! Waveform Output Channel 6 */ #define CHANNEL_PWM_MAC6 #define PIN_TC2_TIOA6 (PIO_PC25_IDX) #define PIN_TC2_TIOA6_MUX (IOPORT_MODE_MUX_B) #define PIN_TC2_TIOA6_FLAGS (PIO_PERIPH_B | PIO_DEFAULT) #define PIN_TC2_TIOA6_PIO PIOC #define PIN_TC2_TIOA6_MASK PIO_PC25 #define PIN_TC2_TIOA6_ID ID_PIOC #define PIN_TC2_TIOA6_TYPE PIO_PERIPH_B #define PIN_TC2_TIOA6_ATTR PIO_DEFAULT
Code: Select all
/** Configure TC2 channel A6 as waveform output. **/ #define TC2_CHANNEL_WAVEFORM 0 #define ID_TC2_WAVEFORM ID_TC6 #define PIN_TC2_WAVEFORM PIN_TC2_TIOA6 #define PIN_TC2_WAVEFORM_MUX PIN_TC2_TIOA6_MUX
Any help would be greatly appreciated. Once I get this figured out my next tasks include SD memory communication over SPI, FTDI programming with SAM-BA, and plenty more.