Closed navr32 closed 1 year ago
I see the OC0AS and C0BF3 bits set in the code so the output is on E4 and F3. E4 is typically not exposed in the devboards (you have to hookup a cable directly to the micro controller), and F3 is not exposed at all.
Could you try D6 and D5 instead? I don't have boards at hand this week. Thanks for all your tests!
Yes because i have test with different setting .. ! i have test each block commented one by one ..first block and commented uncommented to test with variation so with all this setting variation i have no outputs...so even if setting different output port...
Ok, got it. The lgt datasheets were quite confusing on the toggle mode so I probably got something wrong. I'm not directly coding each posible configuration, but encoding relationships instead, and passing them through a constraint solver. I only understood many of the implications of each mode, by using the tool myself 🤫😄. I'll read the atmel datasheets instead and verify directly on the board in the coming weeks. Thanks again for the detailed reports!
after some search i found that the setting for the fastpwm with toggle mode give with webtimer
void setup(){
/ https://dbuezas.github.io/arduino-web-timers/#mcu=LGT8F328P&timer=0&OCnA_OutputPort=D6&OCnB_OutputPort=D5&interruptB=off&timerMode=FPWM&clockPrescalerOrSource=1&CompareOutputModeA=toggle&OCR0A=51 /
noInterrupts();
TCCR0A =
1 << COM0A1 |
1 << WGM01 |
1 << WGM00;
TCCR0B =
1 << WGM02 |
1 << CS00;
OCR0A = 51;
pinMode(D6, OUTPUT);
interrupts();
}
but output nothing..........
some i have found that the toogle mode is with 1 << COM0A0 not on COM0A1..so if i put this :
TCCR0A |= (1 << WGM01)| (1 << WGM00)| (1 << COM0A0) ;
TCCR0B |= (0 << CS02) | (1 << CS00)| (1 << WGM02 );
I have the waveform i expected....but i was thiking the timing not the same you have estimated on web timer giving period about of 3.6µs...on the lgt with set 32mhz internal i have about 3.3µs....with same timer setting....but but when look at web timer graphics more accurately i see that the graphics scale have a bug and bad display time...0 500 1µs 2µs 2µs 3µs 3µs 4µs... so must be 0 500 1µs 1.5µs 2µs 2.5µs 3µS... if i read with correct scale the graph timing is quiet good i think. So again some work to change this perhaps set better accuracy for scaling and have one digit or number display at curve point intersect at timer event ?
I'm taking a look and I see a bug in timers 0 and 2 for all modes (normal, ctc, pcpwm, fpwm) of both atmega and lgt: the bit for clear and toggle are swapped,
The bug also affected:
And the issue with the time scale, that's a very valid point!
Here is how your configuration used to look like (note the decimals in the x axis):
And this is how it looks now (when I release it)
always with lgt8f328p with 1.0.6 and arduino ide 1.8.15 I have try the timer 0 on normal mode with toggle ..no toggle but never have an output ??? i have block the normal loop to avoid arduino core to use timer0 because i was thinking this block the direct use of timer0 but same things. This work with timer3..
void setup(){
/ https://dbuezas.github.io/arduino-web-timers/#mcu=LGT8F328P&timer=0&CompareOutputModeA=toggle&OCR0A=51&CompareOutputModeB=toggle&OCR0B=102 /
//timer0 test TCCR0A = 1 << COM0A1 | 1 << COM0B1; TCCR0B = 1 << CS00; OCR0A = 128; OCR0B = 102; //or others settings //timer0 test // TCCR0A = // 1 << COM0A1 | // 1 << COM0B1; // TCCR0B = // 1 << OC0AS | // 1 << CS00; // PMX0 = // 1 << WCE | // 1 << C0BF3; // OCR0A = 51; // OCR0B = 102;
//timer0 test // TCCR0A = // 1 << COM0A1 | // 1 << COM0B1 | // 1 << WGM01; // TCCR0B = // 1 << OC0AS | // 1 << CS00; // PMX0 = // 1 << WCE | // 1 << C0BF3; // OCR0A = 51; // OCR0B = 20;
//timers3 test work
//TCCR1A = // 1 << COM1A0 | // 1 << COM1B0; // TCCR1B = // 1 << CS10; // OCR1A = 13107; // OCR1B = 26214;
pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(A0, OUTPUT); pinMode(A1, OUTPUT); pinMode(A2, OUTPUT); pinMode(A3, OUTPUT);
interrupts(); }
int main( void ) {
setup(); // Your code goes here while (true) {}; }
void loop() { // put your main code here, to run repeatedly:
}