Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Arduino Due: Setting Up Timers (Read 9001 times)
d.gelman
Newbies
*
Offline


Posts: 6
Joined: Feb 25th, 2015
Arduino Due: Setting Up Timers
Feb 25th, 2015 at 6:11pm
Print Post  
Hello, Community.

I am new to Visual Micro and very excited. I have developed my application using the standard IDE for the Due (currently 1.6).

I use a series of timers, where by I using the following code. This code was provided on the Arduino Forums and I have been very successful with it. It works just fine in the Arduino IDE.

Code (C++)
Select All
// ISR flags
volatile int flagOne = 0;

void setup() {
       startTimer(TC1, 0, TC3_IRQn, 100);  //Initialize Timer
}

// Enable Timer
void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency) {
	pmc_set_writeprotect(false);
	pmc_enable_periph_clk((uint32_t)irq);
	TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
	uint32_t rc = VARIANT_MCK / 128 / frequency; //128 because we selected TIMER_CLOCK4 above
	TC_SetRA(tc, channel, rc / 2); //50% high, 50% low
	TC_SetRC(tc, channel, rc);
	TC_Start(tc, channel);
	tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPCS;
	tc->TC_CHANNEL[channel].TC_IDR = ~TC_IER_CPCS;
	NVIC_EnableIRQ(irq);
}

// TC3 Timer Interrupt Handler
void TC3_Handler()
{
	TC_GetStatus(TC1, 0);
	flagOne = 1;
}
 



As I then ported into Visual Micro, I am getting a red line error when I initialize the timer noting 
"Error: expression preceding parentheses of apparent call must have (pointer-to-) function type"

I am reaching out to ask how to fix this, and possibly explain why porting this code into C# breaks it. I am VERY new to C#.

Thank you all.
dgelman
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Arduino Due: Setting Up Timers
Reply #1 - Feb 25th, 2015 at 7:11pm
Print Post  
Hi,

Thanks for the post. Actually in Visual Studio we are using C++ same as Arduino. C# is for windows applications.

I suspect the breakage is to do with the attempt to intialise debug which will use the Arduino Serial comms. The Serial is tied closely to timers so hopefully that is the issue.

Please un-tick "tools>visual micro>automatic debugging" and try again

If it fails please zip your sketch and email to info [at] visualmicro.com

Thanks
  
Back to top
IP Logged
 
d.gelman
Newbies
*
Offline


Posts: 6
Joined: Feb 25th, 2015
Re: Arduino Due: Setting Up Timers
Reply #2 - Feb 25th, 2015 at 9:09pm
Print Post  
Tim@Visual Micro wrote on Feb 25th, 2015 at 7:11pm:
Hi,

Please un-tick "tools>visual micro>automatic debugging" and try again

Thanks


Thank you for the instructions, unfortunately when I go to Tools>Visual Micro(1.6), I do not see the Automatic Debugging feature. 

Please refer to the attachment.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Arduino Due: Setting Up Timers
Reply #3 - Feb 25th, 2015 at 9:16pm
Print Post  
Hi,

Sorry I didn't read your message properly earlier.

Actually if you try to compile and upload you will find it works just as the arduino ide does

The intellisense system is disconnected from the compiler because normally Visual Studio does not cater for Arduino projects. Visual Micro takes over and performs the compile and not Visual Studio.

So the error you are seeing does not break anything it probably just shows an incompatibility between Microsoft C++ and Gcc C++ (Arduino uses gcc)

The Timer functions are the ones that often cause intellisense issues and we haven't look at them for the Due for a while.

To save some time email your sketch and we can find a solution.

In the meantime you can also open the "Error List", right click and switch off intellisense errors. This will then give you a clean error list when you compile. An example of the error list is in the release notes for the last release
  
Back to top
IP Logged
 
d.gelman
Newbies
*
Offline


Posts: 6
Joined: Feb 25th, 2015
Re: Arduino Due: Setting Up Timers
Reply #4 - Feb 25th, 2015 at 9:58pm
Print Post  
Ah okay, thank you.

I actually never did try to compile, it does work. Is it safe to assume that if the code works on the Arduino IDE, Visual Micro will work, even if errors are shown? I ask this because I notice other red lines including:

1) "Error: identifier "strtok_r" is undefined", when using strtok_r()
2) "Error: expression must have a constant value", when initializing int array with a variable length

Additionally, I am checking the timers and it seems to be working as expected.

With all this said, what would you like to see? The program is fairly large.

dgelman
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Arduino Due: Setting Up Timers
Reply #5 - Feb 27th, 2015 at 8:49pm
Print Post  
Hi,

Sorry for the delay.

Quote:
Is it safe to assume that if the code works on the Arduino IDE, Visual Micro will work, even if intellisense errors are shown


Yes and the code remains the same so can be edited in either visual micro or the arduino ide.

...

Can you please zip and email your sketch and sources to info [at] visualmicro.com

Thanks


  
Back to top
IP Logged
 
d.gelman
Newbies
*
Offline


Posts: 6
Joined: Feb 25th, 2015
Re: Arduino Due: Setting Up Timers
Reply #6 - Mar 2nd, 2015 at 4:16pm
Print Post  
Thank you very much,

I disabled IntelliSense Errors, but it only removed errors in the error list. Is it possible to hide these types of errors in the actually code? I am still getting many red lines that are fairly distracting.

Regarding sending you the code - it is fairly long and involved. What would you specifically want to see? or would you like everything?

Thanks,
Daniel
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Arduino Due: Setting Up Timers
Reply #7 - Mar 2nd, 2015 at 10:08pm
Print Post  
Just an example will do. For example, I guess the error in your screen shot is due to the definition of Tc, the first param?

Any example that will show a few errors will help for now thanks

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint