Is it a datasheet error in the AVR 0/1 series TCB?

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use TCB's single shot mode. The datasheet says that there is a 2 clock delay from the trigger event to the start of the count.(2 to 3 clocks are written elsewhere)
But in reality it is 4 clocks.

The devices I tested were mega3208, mega4809 and tiny1616, but the results were the same.

Is this my mistake?
Please give me your opinion.

 

 

This is the test code for mega0.

Generate a single shot of 4 clock width.

#include <avr/io.h>
#include <avr/interrupt.h>

////////////////////////////////////////////////////////////////
// Fuses
////////////////////////////////////////////////////////////////
FUSES = {
    .WDTCFG     = 0,
    .BODCFG     = 0,
    .OSCCFG     = FUSE_FREQSEL1_bm, // 20MHz
    .SYSCFG1    = 0b00000111,
    .APPEND     = 0,
    .BOOTEND    = 0,
    .SYSCFG0    = 0b11000000,
};

////////////////////////////////////////////////////////////////
// main
////////////////////////////////////////////////////////////////
int main(void){
    // CLOCK set(20MHz)
    _PROTECTED_WRITE((CLKCTRL.MCLKCTRLB), CLKCTRL_PDIV_2X_gc | !CLKCTRL_PEN_bm);
    _PROTECTED_WRITE((CLKCTRL.MCLKCTRLA), CLKCTRL_CLKSEL_OSC20M_gc);

    EVSYS.CHANNEL0 = EVSYS_GENERATOR_TCB1_CMP0_gc;
    EVSYS.USERTCB0 = EVSYS_CHANNEL_CHANNEL0_gc;
    EVSYS.USEREVOUTB = EVSYS_CHANNEL_CHANNEL0_gc;

    // TCB1 1ms Periodic (TCB0 trigger)
    TCB1.CCMP = 20 * 1000 -1;
    TCB1.CTRLB = TCB_CNTMODE_INT_gc;
    TCB1.CTRLA = TCB_CLKSEL_CLKDIV1_gc | TCB_ENABLE_bm;

    // TCB0 4clk width 1shot
    TCB0.CCMP = TCB0.CNT = 3;
    TCB0.EVCTRL = TCB_CAPTEI_bm;

    // TEST parameter
    TCB0.CTRLB = TCB_CNTMODE_SINGLE_gc | TCB_CCMPEN_bm;
//  TCB0.CTRLB = TCB_CNTMODE_SINGLE_gc | TCB_CCMPEN_bm | TCB_ASYNC_bm;

    TCB0.CTRLA = TCB_CLKSEL_CLKDIV1_gc | TCB_ENABLE_bm;
//  TCB0.CTRLA = TCB_CLKSEL_CLKDIV_gc | TCB_ENABLE_bm;

    sei();
    while (1) {
    }
}

 

This is the output waveform.
You can see that it takes 4 clocks to start up single shot.

 

This is the output waveform in asynchronous mode.
The event is received without delay and the output is transitioning to H immediately.

This topic has a solution.
Last Edited: Thu. Jun 13, 2019 - 03:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, yeah, judging from the traces it looks like 4 cycles.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems to be common for 0/1 series datasheets to have errors, you should open a ticket at MC and submit your error report.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am currently thinking about software that actively incorporates this delay.

 

Even if this reality is contrary to the intention of the silicon designer, it is fine if it can be fixed as a standard specification of future products. In that case, if there is an official announcement as errata, you can feel safe. Therefore I wanted to leave a trace in some knowledge base.

The worst scenario for me is that the silicon is corrected to the data sheet behavior by a revision upgrade. However, in the situation where many chips have already been released, I think that possibility is low.

 

I did not know the keyword "ticket". By search this seems to be useful information. I will continue my efforts.
Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


kabasan wrote:
The worst scenario for me is that the silicon is corrected to the data sheet behavior by a revision upgrade

Errata is a normal way of life, and common in data sheets, here is an example of of a h/w change starting with rev K of the M328

There are some MAJOR changes listed here (like the device ID changing) , and begs the need for constant updating of your data sheet library!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, the worst case possibilities are not zero. I carefully create software.

 

Did the "Support Ticket" change its name to "technical support case"?

Since I am not very familiar with PIC, I have my account, but I do not understand the Microchip site well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kabasan wrote:
"technical support case"?

That would be it!

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel never took the job to make datasheets serious so they had a lot of errors. 

 

And unfortunately it look's like Microchip don't care either. 

 

But in general the simulator seems to be correct (it's supposed to be made from the chip design itself), so perhaps try to simulate it, and if you see the same there it's how it's supposed to work, and perhaps the datasheet one day will be updated.     

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


@kabasan:

 

As you know, TCB is synchronous to the system clock, so based on your experiment I decided to see what is the response to an asynchronous trigger.

I used the PIT with the internal 32kHz oscillator, and observed a 3-4 cycle delay, so +1 than stated in the datasheet (2-3 cycles). This is a capture with a short delay, 160ns, a bit more than 3 cycles:

 

 

#include <avr/io.h>

inline void clock_init();
inline void event_init();
inline void pit_init();

////////////////////////////////////////////////////////////////
// main
////////////////////////////////////////////////////////////////
int main(void){
	clock_init();
	event_init();
	pit_init();

	// TCB0 4clk width 1shot
	TCB0.CCMP = TCB0.CNT = 3;
	TCB0.EVCTRL = TCB_CAPTEI_bm;

	// TEST parameter
	TCB0.CTRLB = TCB_CNTMODE_SINGLE_gc | TCB_CCMPEN_bm;
	//  TCB0.CTRLB = TCB_CNTMODE_SINGLE_gc | TCB_CCMPEN_bm | TCB_ASYNC_bm;

	TCB0.CTRLA = TCB_CLKSEL_CLKDIV1_gc | TCB_ENABLE_bm;
	//  TCB0.CTRLA = TCB_CLKSEL_CLKDIV_gc | TCB_ENABLE_bm;

	while (1) {
	}
}

void clock_init() {
	// CLOCK set(20MHz)
	_PROTECTED_WRITE((CLKCTRL.MCLKCTRLB), CLKCTRL_PDIV_2X_gc | !CLKCTRL_PEN_bm);
	_PROTECTED_WRITE((CLKCTRL.MCLKCTRLA), CLKCTRL_CLKSEL_OSC20M_gc);
}

void event_init() {
	EVSYS.CHANNEL1 = EVSYS_GENERATOR_RTC_PIT3_gc;
	EVSYS.USERTCB0 = EVSYS_CHANNEL_CHANNEL1_gc;
	EVSYS.USEREVOUTB = EVSYS_CHANNEL_CHANNEL1_gc;
}

void pit_init(void){
	RTC.CLKSEL = RTC_CLKSEL_INT32K_gc;
	RTC.PITCTRLA = RTC_PITEN_bm;
}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for patting my head.

 

Certainly the simulator is not based on a real chip but based on its design. Unfortunately, I do not know how to capture changes in IO pins that do not go through the CPU.

 

Oh, El Tangas reminds me that there is also a mistake.
I forgot that there is an inevitable one clock gap between the output timing of TCB1 and the timing when TCB0 samples that change.
The delay of single shot activation excluding it is 3 clocks. I got close to the datasheet for one clock.

 

By the way, I want to ask when I was embarrassed.
How do I insert such a citation into a post?
I could not find the tutorial.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kabasan wrote:

Certainly the simulator is not based on a real chip but based on its design.

The simulator models in Studio are made by taking the exact same synthesizable RTL code used to make the device, and run it through Verilator. Timers and event system is all synthesizable and are cycle accurately modeled. No human intervention. :-)

Non-synthesizable parts, like flash, needs to be remodeled, but we strive to make even those cycle accurate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did not know that there was no human intervention.
It seems that there is no need to immediately focus on confirmation on the simulator.

 

I'm still looking at the code and oscilloscope to guess what's going on in the internal circuit.
Although I do not yet understand it, I felt that the circuit worked as the designer intended, simply because the explanation of the data sheet was simply insufficient.

After all that might be a mistake due to my lack of understanding.

 

There are some other strange behaviors that are interesting.
And I'm tired.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


kabasan wrote:
By the way, I want to ask when I was embarrassed.

How do I insert such a citation into a post?

 

You select the text, then hit the "quote" button:

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you very much.
I also learned one of the functions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

kabasan wrote:
The worst scenario for me is that the silicon is corrected to the data sheet behavior by a revision upgrade

Errata is a normal way of life, and common in data sheets, here is an example of of a h/w change starting with rev K of the M328

There are some MAJOR changes listed here (like the device ID changing) , and begs the need for constant updating of your data sheet library!

 

Jim

 

If I remember correctly this errata turned into the "PB" family. So you won't get rev.k  chips, but rather the new "PB" family ones.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rammon wrote:

ki0bk wrote:

kabasan wrote:
The worst scenario for me is that the silicon is corrected to the data sheet behavior by a revision upgrade

Errata is a normal way of life, and common in data sheets, here is an example of of a h/w change starting with rev K of the M328

There are some MAJOR changes listed here (like the device ID changing) , and begs the need for constant updating of your data sheet library!

 

Jim

 

If I remember correctly this errata turned into the "PB" family. So you won't get rev.k  chips, but rather the new "PB" family ones.

 

I used the M328 as an example only, consult latest DS's errata section for the chip in use.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I think that I was able to raise a problem even with my poor communication skills.
I was able to record many operation examples, and I send it to the microchip in order.

 

I just don't like using the versatile TCA for the waveform generation of WS2812B RGB-LEDs in AN2387, and just wanted to replace it with a TCB. And it was completed today.

 

Jim's post, which showed me where to report, will be the solution, and my submission will be closed once.