SparkFun Forums 

Where electronics enthusiasts find answers.

Hardware or product specific questions are best asked here.
User avatar
By senaex
Hello there,
I'm trying to connect my RC Receiver to a Redboard Artemis, the Problem is, reading the pulse lenght from the receiver isnt as easy as I thought. I previosly worked with an Arduino Uno and upgraded to the Redboard because of the faster cpu, so I searched in the apollo 3 Datasheet for possible methods to count how long it takes between the choosen pin to get high and low. I could use the commands in the arduino IDE, but for my purposes I need a quick way to read 6 pins, so I prefer direct Register Manipulation. Many other microcontroler got a method called Input Capture Mode and it works like this: "Embedded systems using input capture will record a timestamp in memory when an input signal is received. It will also set a flag indicating that an input has been captured. This allows the system to continue executing without interruption while an input is being received while still having the capability to trigger events based on the exact time when the input was received".
I now I copy and pasted it, but as far as i know, the apollo 3(Redboard Artemis) isnt capable of doing this.

So my final question is: How can i get precised Pulse Capture with the Redboard Artemis?
Thank you in advance for the help.
User avatar
By liquid.soulder
Two ways:
1. use the pulseIn() function in Arduino. That would be the easy solution, but it uses polling.
2. use interrupts on signal changes, and record when these happened. You could so this with Arduino functions (attachInterrupt, microseconds) or at a lower level (using the Ambiq HAL or direct register manipulation if you want)
User avatar
By senaex
Ok, I would prefer the second method with direct register manipulation. All i have to is to configure a timer/counter with the registers and set up an interrupt for high->low andlow->high pin changes. I already know how to set up an interrupt with the regsiters, but how do I write the specific code that is executed whenever the interrupt accours? I mean how do I tell the Arduino IDE what it should do with the interrupt?
User avatar
By senaex
So as I don't know how I programe an interrupt yet, i decided to simply try to get a timer to work.
For each timer there are 7 corresponding 32 bit regsiters(apollo 3 datasheet). I wrote a little test programm, that simply reads the timer value and prints it on the serial monitor.
Code: Select all
uint32_t Timer0;

void setup() {
  /////////////TIMER CONFIG///////////////////////////
  CTIMER->CTRL0 = (6 << 1) | CTIMER->CTRL0;
  CTIMER->CTRL0 = (6 << 6) | CTIMER->CTRL0;
  CTIMER->AUX0 = 0;
  CTIMER->AUX0 = (1 << 11) | CTIMER->AUX0;
void loop() {
  Timer0 = CTIMER->TMR0;

So i uploaded the code and the serial moniter just shows zero's Image, but when i restart the serial monitor a couple of times, somehow the timer starts counting Image. If I restart it again it shows 0.
Maybe there is a problem with the serial monitor. But weirdly when I try to change the clock source from this:
CTIMER->CTRL0 = (6 << 1) | CTIMER->CTRL0;
to this: CTIMER->CTRL0 = (1 << 1) | CTIMER->CTRL0;. Image The timer just doesn't work at all (only zeros).
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]