Arduino Due on a Breadboard

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
ajienikicio
 
Posts: 26
Joined: Tue Aug 27, 2013 11:20 pm

Re: Arduino Due on a Breadboard

Post by ajienikicio »

My mistake, it turned out that I didn't properly set the sysclock configuration to use systick and so it always got into the exception handler every time I tried to use the systick.

Now I can run the code (blink LED) normally, but this time there's always a pop-up whenever I pause the program, saying that it doesn't know which part of the source code it is currently at (screenshot is attached). I suspect it's because of the while statement in the delay function, but still I find this odd. Is this actually normal? I attached my main.c below

Code: Select all

#include "asf.h"

volatile uint32_t g_ul_ms_ticks = 0;

static void SysTick_Handler(void){
	g_ul_ms_ticks++;
}

void mdelay(uint32_t ul_dly_ticks){
	uint32_t ul_cur_ticks;
	int a = 0;
	
	ul_cur_ticks = g_ul_ms_ticks;
	while ((g_ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks);
}

int main (void)
{
	sysclk_init();
	board_init();
	
	if (SysTick_Config(sysclk_get_cpu_hz() / 1000))	{
		//Systick configuration error
		while (1);
	}
		
	while(1)
	{
		gpio_set_pin_low(PIO_PA14_IDX);
		mdelay(1000);
		gpio_set_pin_high(PIO_PA14_IDX);
		mdelay(1000);			
	}
}
Attachments
No Source Available error.jpg
No Source Available error.jpg (537.01 KiB) Viewed 1349 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

If you're just randomly pausing, it's not all that unusual. You're probably pausing it while it's inside some ASF routine or library routine.
If you set a breakpoint in your code, then it knows where you are, right?

User avatar
ajienikicio
 
Posts: 26
Joined: Tue Aug 27, 2013 11:20 pm

Re: Arduino Due on a Breadboard

Post by ajienikicio »

Hello again Rick,

Thank you for the earlier replies! I'm still working on my project and I have a few questions regarding the use of SAM3 based custom board and Atmel Studio again:

1) Can I make use of libraries written in C++? The Atmel Studio project I'm working on is a C project

2) I really need a print function to the Atmel Studio (just like the Serial Monitor in Arduino IDE). Currently I don't have USB on my custom board. Once I get the USB circuit connected to my chip, are there anything else I need to do to make use of the printf function for debugging via USB?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

ajienikicio wrote:1) Can I make use of libraries written in C++? The Atmel Studio project I'm working on is a C project
That gets ugly in a hurry. You would be better off to make your main project a C++ project. The code won't have to look any different - you can write straight C in a C++ program. In fact, when you write an Arduino sketch, you are actually using C++. If you wanted to add a class to an arduino sketch, you could do that.
ajienikicio wrote:2) I really need a print function to the Atmel Studio (just like the Serial Monitor in Arduino IDE). Currently I don't have USB on my custom board. Once I get the USB circuit connected to my chip, are there anything else I need to do to make use of the printf function for debugging via USB?
You would go into the ASF and instantiate a USB serial device. I haven't done that, so I don't know what else you have to do to get printf working. It might be easier to hook up to one of the UARTs on the chip. I really don't know.

User avatar
ajienikicio
 
Posts: 26
Joined: Tue Aug 27, 2013 11:20 pm

Re: Arduino Due on a Breadboard

Post by ajienikicio »

Regarding the C++ usage,

Is there anything I need to take care of if I want to use the ASF libraries in a C++ project?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

I don't think so.

User avatar
ajienikicio
 
Posts: 26
Joined: Tue Aug 27, 2013 11:20 pm

Re: Arduino Due on a Breadboard

Post by ajienikicio »

Rick,

Have you ever interfaced a microcontroller with XBee using Atmel Studio? I'm currently looking for a library based on C for that. I've only experienced with using the Arduino library, which is based on C++. I'm going to try making my Atmel Studio main project a C++ project, making use of the Arduino library, and see how it goes though

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

I've never done anything with an XBee. But it should appear to you as a regular UART.

owais
 
Posts: 1
Joined: Fri Jan 17, 2014 6:30 am

Re: Arduino Due on a Breadboard

Post by owais »

Hello,

I am working with custom SAM3X8C board using SAM-ICE to program it using Atmel STudio 6. i would like to know if there is a way to reset the microncontroller over SAM-ICE through Atmel Studio 6 with out programming it? I am trying to avoid unplugging the power to the board to do a reset.

Thanks.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

There's a Reset item in the Debug menu (Shift+F5)

User avatar
amahpour
 
Posts: 108
Joined: Mon Feb 03, 2014 4:16 pm

Re: Arduino Due on a Breadboard

Post by amahpour »

Hi Rick,

So from what I am reading it seems like ajienikicio basically started an Atmel project from scratch. Is there no simple way to just write a sketch in the Arduino IDE and then program using JTAG? I understand the Arduino IDE does not support JTAG but is there a way to just migrate over to the Atmel Framework in a few simple steps?

User avatar
amahpour
 
Posts: 108
Joined: Mon Feb 03, 2014 4:16 pm

Re: Arduino Due on a Breadboard

Post by amahpour »

I think that link you provided from Visual Micro answered my question. Perhaps you have experimented with this tool?

july 2014 news for advanced users: new release - supports the new ATMEL-ICE programmer for Arduino SAM and AVR (as ISP)
http://www.visualmicro.com/page/Arduino ... tudio.aspx

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

I have used the Arduino support in Atmel Studio. It works as advertised.
I've also developed code, programmed and debugged a Due via JTAG in just plain vanilla C++ in Atmel Studio

User avatar
amahpour
 
Posts: 108
Joined: Mon Feb 03, 2014 4:16 pm

Re: Arduino Due on a Breadboard

Post by amahpour »

Hi. Thanks for the quick reply.

So, in theory, I should be able to take my .ino file and put it on an Atmel SAM3X dev board?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Due on a Breadboard

Post by adafruit_support_rick »

In theory. No guarantees. ;)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”