Recent

Author Topic: Extra help debugging for 4 separately used PWM channels, with the atmega328p  (Read 227 times)

pascalbythree

  • Sr. Member
  • ****
  • Posts: 286
Can somebody please help me out debugging this peace of source code ?

Code: Pascal  [Select][+][-]
  1. ModePortB(1,true);
  2.     TCCR1A := (%10 shl COM1A) or (%10 shl COM1B) or (1 shl WGM1);    
  3.     TCCR1B := TCCR1B or %101;
  4.     OCR1B := 125; // INTERNAL LIGHT EFFECT     
  5.        
  6. ModePortB(2,true);
  7.     TCCR1A := (%10 shl COM1A) or (%10 shl COM1B) or (1 shl WGM1);    
  8.     TCCR1B := TCCR1B or %101;    
  9.     OCR1A := 125; // LED BAR 4 
  10.  
  11. ModePortD(6,true);
  12.     TCCR1A := (%10 shl COM0A) or (%10 shl COM0B) or (1 shl WGM1);    
  13.      TCCR1B := TCCR1B or %101;  
  14.         OCR0A := 125; // LED BAR 5
  15.  
  16. ModePortD(5,true);
  17.     TCCR1A := (%10 shl COM0A) or (%10 shl COM0B) or (1 shl WGM1);    
  18.     TCCR1B := TCCR1B or %101;
  19.         OCR0B := 125; // LED BAR 6

The INTERNAL LIGHT EFFECT and the LEDBAR 4 blinks just fine.

What to change to get the LED BAR 5 and LED BAR 6 channel to work at the same time?

PS: It has to run 4 different values.

Greets, Wouter van Wegen

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
TCCR0A/B instead of 1?

pascalbythree

  • Sr. Member
  • ****
  • Posts: 286
Code: Pascal  [Select][+][-]
  1.         // SETTTING ALL PWM MODUS FOR 4 DRIVERS
  2.     ModePortB(1,true);
  3.     TCCR1A := (%10 shl COM1A) or (%10 shl COM1B) or (1 shl WGM1);    
  4.     TCCR1B := TCCR1B or %010;
  5.     OCR1B := 0; // INTERNAL LIGHT EFFECT       
  6.  
  7.     ModePortB(2,true);
  8.     TCCR1A := (%10 shl COM1A) or (%10 shl COM1B) or (1 shl WGM1);    
  9.     TCCR1B := TCCR1B or %010;    
  10.     OCR1A := 0; // LED BAR 4   
  11.  
  12.     ModePortD(6,true);
  13.     TCCR0A  := (%10 shl COM0A) or (%10 shl COM0B) or (1 shl WGM1);    
  14.     TCCR0B := TCCR1B or %010;  
  15.         OCR0A := 0; // LED BAR 5
  16.        
  17.     ModePortD(5,true);
  18.     TCCR0A  := (%10 shl COM0A) or (%10 shl COM0B) or (1 shl WGM1);    
  19.     TCCR0B := TCCR0B or %010;
  20.     OCR0B := 0; // LED BAR 6

Thank you, it got to work already like this!

 

TinyPortal © 2005-2018