Author Topic: Atmel SAM D - TC and TCC (no ASF)  (Read 13338 times)

0 Members and 1 Guest are viewing this topic.

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: Atmel SAM D - TC and TCC (no ASF)
« Reply #25 on: November 07, 2016, 11:43:30 pm »
I tried again but no success. When I press the Button, my software is blocking in wait_start() function, that is, only doing PA09 muxed continuosly, then my OLED blocks.
You've already got a thing to try with synchronization. It looks like it is necessary for TCC.

I tested 64.
Have you adjusted anything else to accommodate this change?

I thought it is not necessary to use because I want only the CC[] match.
What exactly should happen on CC[] match?

PER defines PWM frequency, CC[] define duty cycle. Both are necessary for operation.


Code: [Select]
do
 {
  prev = TCC0->COUNT.reg;
 }
        while (TCC0->SYNCBUSY.bit.CTRLB);
TCC0->CTRLBSET.bit.CMD = TCC_CTRLBSET_CMD_READSYNC_Val;
while (TCC0->SYNCBUSY.bit.CTRLB);
while (TCC0->COUNT.reg >= prev);
}
You need to do this inside the loop, not just some random place.

You really need to pause on this project and just play with MCUs in general. You also need to learn how to use a real debugger. Your Xplained board comes with one, use it.

This case is also a good example why you should not have messy code. Always enforce coding style. It pays in the long run.
Alex
 

Offline FrancTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: br
Re: Atmel SAM D - TC and TCC (no ASF)
« Reply #26 on: November 14, 2016, 12:13:35 pm »
Quote
You need to do this inside the loop, not just some random place.
Dear Alex, that day it was my last try. I had tested in all ways. Including in loop.

I am pretty right that my issue is in 'while (TCC0->COUNT.reg >= prev);' because the program blocks in 'void wait_start()' function.

Quote
You really need to pause on this project and just play with MCUs in general.
I don't want stop, it is a very simple code. Remember this forum is for students also . These posts will help a lot of students as me in the future..

Alex/Lajon, could I send my complete code to you check for help me? Really it does not work and I donĀ“t have idea where  I am wronging.

Regards!
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: Atmel SAM D - TC and TCC (no ASF)
« Reply #27 on: November 14, 2016, 04:50:59 pm »
I am pretty right that my issue is in 'while (TCC0->COUNT.reg >= prev);' because the program blocks in 'void wait_start()' function.

There is no way for me to teach you how to debug the code remotely. Here is a start though. Write this code, after TCC initialization:
Code: [Select]
  volatile int cnt;
  while (1)
  {
        while (TCC0->SYNCBUSY.bit.CTRLB);
TCC0->CTRLBSET.bit.CMD = TCC_CTRLBSET_CMD_READSYNC_Val;
while (TCC0->SYNCBUSY.bit.CTRLB);
        cnt = TCC0->COUNT.reg;
  }
Step thoguh it in the debugger, or print out the values of cnt. Don't move on to anything else until this loop prints non-zero numbers.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf