Replies: 6 comments 4 replies
-
There's something going on there that doesn't add up. The internal oscillators on these parts are dead on accurate IME, never seen one that was even 1% off it's target under normal conditions. That would be miles out of spec even on a classic AVR, and the oscillator is far better on these parts. Which part are you using? What method do you use to generate the PWM? What else is the program doing? To rectify a problem like this you need to first identify what is actually happening and the one thing I'm certain of is that you don't have as clue what's wrong. I don't either, but that's not a surprise, since I can't see your code nor look at your board layout (though I have trouble imagining how you'd manage a 30% timing error through poor PCB design, I also know nothing about your design.). If it was 25% fast or 20% slow, then easy, the OSCCFG fuse is set wrong. Much more debugging effort is required here, and if you want my thoughts on this, I'd need to see the code and schematic. |
Beta Was this translation helpful? Give feedback.
-
Hi Thanks for the replies. I have done some digging and it would appear it is something to do with my code (no surprise!!). If I load the TCA0Demo4 code into a out of spec board it works at the specified frequency so it would appear the chips are fine. TCA0.SPLIT.CTRLD = TCA_SPLIT_SPLITM_bm; |
Beta Was this translation helpful? Give feedback.
-
When the boards are in front of you?! Real developers debug hardware thile the hardware is behind their back... shrug So you're timing a moderately high frequency input? How you going about that? My prediction is that there's a bug in how you're approaching that, and so with no input, it is going off in a direction you don't expect. And what timer are you using for millis, if you have that enabled? (I would imagine TCD0 as all 1-series should be defaulting, so that wouldn't have a notable impact unless you were using that to time the other pin with - and if you're doing THAT, you should also be debugging them with the boards behind you and your hands tied up with the power cable, because you are trying to make life harder for yourself; the TCD is an awful timer for capture...). In that vein though,, if not using millis()., micros(), or delay() in your sketch,, definitely disable millis if you're using a 2k part. Saves couple hundred bytes in many circumstances. (the TCD is one of the most complicated, uncooperative, and byzantine peripherals found on a mainstream non-xMega AVR [on xmega, every peripheral is complicated and byzantine - the xmega line combines the complex mess that peripherals turn into when engineers are given cheap transistors and nobody holds their leash on usability or usefulness, with the limitations of the AVR instruction set - my theory on why they didn't really take off is that anyone who was prepared to deal with that kind of learning curve would just learn some ARM architecture that's more widely applicable.). The fact that TCD0 is difficult to work with is WHY it is the default timer for millis on parts that have it - the chance of someone wanting to reconfigure it is practically zero, so using it for millis leaves the timers they would be likely to play with available. Even at that, I only use it on megaTinyCore - Dx parts have enough TCB's that I just throw one of those at millis by default; I'll probably support TCD millis over there for the DD-series parts, since they only have 2 TCBs on the 14 and 20 pin devices, and that's not enough to be able to require that either a TCB or the only TCA be used if one wants millis() ; I consider 2 TCBs vs 3 TCBs to be the dividing line between a comfortable number of timers and feeling confined and limited by the number of available timers. Maybe a hypothetical device with 64k+ flash and >40 I/O pins to feel limited by the timers even with 3 TCBs, but I'd have to meditate on that question... if it had a second TCA, I don't think I'd start sweating if I couldn't move millis timekeeping to a TCD.. And a hypothetical 8-pin tiny with 2 TCBs, I think would also feel comfortable. Anything between those extremes, with 3 TCBs you can burn one for millis and feel okay with that because you've still got 2 to play with, and so you can use one before you're in the danger zone, while with only two, if you burn one for millis, using the remaining one is a declaration that you've forseen all eventualities that would force you to to use a TCB, which is a bit intimidating - like trading your car key to some dude along the roadside. However compelling the trade he's offering is, you'd better be real sure the next town is as close by as you think it is, you know?... But I digress - I digressed very very far didn't I?) |
Beta Was this translation helpful? Give feedback.
-
Hi, lol yes you digressed very far and I hardly understood a word of it. I am using the arduino 'pulseIn' command to measure the incoming signal. What is strange is that boards that were reading 2.39KHz are now reading 3.1KHZ if I re-program them. Changing the 99 value to 130 I can get them all to output approx. 2.39KHz. |
Beta Was this translation helpful? Give feedback.
-
Hi
I have developed a board that outputs a 50/50 pwm at 2.39Khz. This is running an internal clock speed of 20MHz.
The prototype has worked fine but on a production batch of 100 boards I have about 20% reject rate where the output pwm is approx 3.1KHz.
They are all running the same program and the fuse settings are all the same as well.
As the program is the same I am assuming this is the speed of the internal clock is out. Is there a way to correct this?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions