Go Down

Topic: Nano every does not accept loads after changing prescaler timer TCA (Read 112 times) previous topic - next topic

ronaldus1

Hi All,

This is my first message here.

I programmed a lot with Atmel microcontrollers but this is the first time with arduino.

I have an Arduino Nano Every and I could always upload sketches without any problems.  I was experimenting with the prescaler settings in the timer TCA0 and I increased it from the default 64 to 256 and 1024. After changing it to 1024 I could not upload any sketches anymore.  The program inside runs fine 
It's just a test program that uses a pin interrupt and runs the servo library and I set the timer TB1 to PWM mode 50% duty cycle with the TCACLK as clock source. the I changed the TCA0.CTRLA to the different dividers 

How can I de-block the situation?
I think about one that I didn't try:  reducing the upload speed (in the boards.txt settings) I think that serial timings could be affected

It there a way to reset the every to factory settings?

Ideas anybody?

Regards,

Ron.

ronaldus1

After one day i tried to upload again a sketch and now it works.

I switched to verbose mode and it uploaded without any problems!

Strange!

Thanks anyway,

Regards,

Ron.


almytom

I'm glad you got it running, but let's address the original problem. 

Since you said you've had non-Arduino Atmel AVR experience before, you are probably used to using an AVR-ISP and program over the ICSP interface. While you can program other AVR based Arduino boards that way, they normally are  programmed via a bootloader program within the AVR that understands the AVR-ISP's command set and thus can be programmed via AVRDUDE on the host computer. If the bootloader gets destroyed then the only way to recover is to use an AVR-ISP. Only by using an AVR-ISP can the fuses be changed.

Unlike other AVR based Arduinos the ATmega4809 in the Nano Every has no bootloader program but gets programmed over the one-wire UPDI interface through the auxiliary SAM microcontroller on the board. This means that there is basically nothing you can do to brick the AVR on this board. Loading programs completely reset the AVR each time, including setting all the fuse bits.

ronaldus1

Hi all,

Thanks for the reply.
@almytom:

You are right I'm used to programming via spi. And it's good to know that I cannot brick the nano every.

Finally the problem came back but it I can work around it.  
What happens is the following:
At random moments during upload avrdude throws a message that the com port is busy and it times out.
What I have to do is disconnect USB and switch off the power for the nano every.
I then connect everything back and I can upload again.

Now I'm programming on a very old laptop (MacBook Pro from 2006 running windows 10 64 bit) maybe the USB port on that machine could provoke some problems.  Although I never had problems before I reprogrammed the TCA0 and TCB3 timers.
The TCB3 timer runs now on his local clock 16Mhz DIV2 and I changed some settings in timer.h
and I get millis() and micros() to work fine. Now I have timer TCA free to use for something else.

Code: [Select]
#define TIME_TRACKING_TIMER_PERIOD    7999  // To get exactly 1ms with the /2 prescalar
#endif
#define TIME_TRACKING_TICKS_PER_OVF   (TIME_TRACKING_TIMER_PERIOD + 1)  // Timer ticks per overflow of TCB3
#define TIME_TRACKING_TIMER_DIVIDER   2   // Clock divider for TCB0
#define TIME_TRACKING_CYCLES_PER_OVF  (TIME_TRACKING_TICKS_PER_OVF * TIME_TRACKING_TIMER_DIVIDER)

Regards,
Ron.




almytom

All changes to the timers I made as well! They basically configured the part to be as compatible with the Uno as possible, to the point that it is really detrimental to the best operation of the part! Having the microsecond timer with resolution of 4 microseconds made it compatible but frankly dumb! 



ronaldus1

Yes you're right. I took all the information  from the web. No inventions from my side.

I use the timer TCA0 for a slow PWM signal for a servo motor as zoom controller for a photo lens. With the orignal code for servo the signal was jittering a lot when using a pin change interrupt at the same time.  Now it is super stable and when the servo is at zero speed there is no humming audible.

Thanks again for your reply,

Regards,

Ron.



  

Go Up