|
Post by hobie1978 on Jun 14, 2017 11:05:59 GMT
Is it possible to run this command in the setup of core 0?
CreateTimerInterrupt0_Core1(ContinuousTimerInterrupt, 10000, STM1_inttest0);
Then it will be possible to execute some function in core 0 before starting the interrupt in core 1. Or doesn't it matter if you run it in setup() or setup1()?
|
|
|
Post by Admin on Jun 16, 2017 12:29:18 GMT
The latest add-in release has a new function which you might find useful!
There is a new 9-channel general purpose timer interrupt facility. This allows periodic interrupts to be created from any core, using the ATOMs in the GTM. This example sets up three interrupts that will call user defined handler functions:
// Set user handler functions TimerConfig[0].user_inthandler = UserTimer0Handler; TimerConfig[1].user_inthandler = UserTimer1Handler; TimerConfig[2].user_inthandler = UserTimer2Handler;
// Initialise general timer channels InitialiseAtomTimerChannel(0); InitialiseAtomTimerChannel(1); InitialiseAtomTimerChannel(2);
// Set period of timer interrupts SetAtomTimerChannelPeriod(0,0x8000); // 32768 * 0.02us period SetAtomTimerChannelPeriod(1,0x4000); // 16384 * 0.02us period SetAtomTimerChannelPeriod(2,100000); // 100000 * 0.02us period
|
|
|
Post by sufi on Apr 24, 2018 13:35:58 GMT
Hi, Can anybody tell me how to use attachinterrupt() in shield Buddy. I used standard arduino " interrupts(); attachInterrupt(digitalPinToInterrupt(MotorEncoder_A_PIN), read_Motorquadrature, CHANGE);" function but its not working. Same works for mega. Pleaese Help
|
|
|
Post by Admin on Apr 24, 2018 14:45:52 GMT
The attachInterrupt() only works for pins 2, 3, 15, 18, 20, 52 on the ShieldBuddy!
|
|
|
Post by sufi on Apr 25, 2018 6:53:25 GMT
Dear Admin, Many Thanks for the reply. I am using 15 and 18 pins for my encoder Ch A and Ch B. But it's not working. On the other hand same works for mega with pins 20 and 21. Waiting for the help Thanks
|
|
|
Post by Admin on Apr 25, 2018 7:31:15 GMT
Try this working example on pins18 and 15!
AttachInt.ino (2.83 KB)
BTW: there is a built-in quad encoder input on Aurix P2.6/7/8, ShieldBuddy Pin D8, D9, D51.
|
|
sufi
New Member
Posts: 4
|
Post by sufi on Apr 25, 2018 8:04:22 GMT
Thanks a Lot. It's working with "AttachInt.ino"
|
|
|
Post by Admin on Apr 25, 2018 8:15:20 GMT
This example uses the built-in incremental encoder function on the Aurix GPT12....
EncoderGPT12.ino (5.08 KB)
It simulates an encoder on pins D2 and D3 and the encoder input is on D8 and D9. D51 is the index input.
|
|
sufi
New Member
Posts: 4
|
Post by sufi on Apr 25, 2018 10:36:52 GMT
Does "built-in incremental encoder" works in both directions?
The "attachinterrupt()" works in one direction only. The code below works in both directions on mega2560. ******************************************************************** uint32 volatile MotorPosition = 0;
void read_Motorquadrature(void);
#define MotorEncoder_A_PIN 15 // #define MotorEncoder_B_PIN 18 // void setup() { pinMode(MotorEncoder_A_PIN, INPUT); pinMode(MotorEncoder_B_PIN, INPUT); attachInterrupt(digitalPinToInterrupt(MotorEncoder_A_PIN), read_Motorquadrature, CHANGE); } void read_Motorquadrature() { // found a low-to-high on channel A if (digitalRead(MotorEncoder_A_PIN) == HIGH) { // check channel B to see which way if (digitalRead(MotorEncoder_B_PIN) == LOW) MotorPosition++; else MotorPosition--; } // found a high-to-low on channel A else { // check channel B to see which way if (digitalRead(MotorEncoder_B_PIN) == LOW) MotorPosition--; else MotorPosition++; } } /****************************************************************************************************/ This code works in both directions on mega2560
|
|
sufi
New Member
Posts: 4
|
Post by sufi on Apr 25, 2018 11:02:27 GMT
"EncoderGPT12.ino" working in both Directions. 
|
|
|
Post by Admin on Apr 25, 2018 14:02:00 GMT
I would use the EncoderGPT12 as it is based on real hardware.
|
|
sufi
New Member
Posts: 4
|
Post by sufi on May 3, 2018 11:17:45 GMT
Dear Admin, While compiling built in example"GenTimersTest", I am getting the following error.
"GenTimersTest:54: error: 'TimerConfig' was not declared in this scope" Could you please help me in solving this issue. I want to print my data using timer in core 2 without disturbing my code. Regards
|
|
|
Post by clemlsn on Jul 3, 2018 14:48:53 GMT
Hello,
I'd have a question about the CreateCorexInterrupt functions, do you know the C code corresponding to these functions ? I found the extern void in the Variant.h file but I can't find the corresponding C code.
Regards, Clement
|
|
|
Post by Admin on Jul 5, 2018 7:25:06 GMT
The source code for these is not included in the standard ShieldBuddy distribution. These functions are based on the TC275 system timer (STM).
|
|