Go Down

Topic: generate four pwm pulse (Read 541 times) previous topic - next topic

farbodpm

hello

 I got a new Arduino 101 and I want to use it instead of Arduino 2560. I have some problems in using timers. can any one help me.

thanks

here is tha part that I have problem with:

void MotorSetup(){
  pinMode(Joy1,OUTPUT);
  pinMode(Joy2,OUTPUT);
  pinMode(Joy3,OUTPUT);
  pinMode(Joy4,OUTPUT);
  TCCR3A=(1<<COM3A1) | (0<<COM3A0) | (1<<COM3B1) | (0<<COM3B0) | (1<<COM3C1) | (0<<COM3C0) | (1<<WGM31) | (0<<WGM30);
  TCCR3B=(0<<ICNC3) | (0<<ICES3) | (1<<WGM33) | (1<<WGM32) | (0<<CS32) | (1<<CS31) | (0<<CS30);
  TCNT3H=0x00;
  TCNT3L=0x00;
  ICR3H=0x6A;
  ICR3L=0x8F;
  OCR3AH=0x00;
  OCR3AL=0x00;
  OCR3BH=0x00;
  OCR3BL=0x00;
  OCR3CH=0x00;
  OCR3CL=0x00;
 
  TCCR4A=(1<<COM4A1) | (0<<COM4A0) | (1<<COM4B1) | (0<<COM4B0) | (1<<COM4C1) | (0<<COM4C0) | (1<<WGM41) | (0<<WGM40);
  TCCR4B=(0<<ICNC4) | (0<<ICES4) | (1<<WGM43) | (1<<WGM42) | (0<<CS42) | (1<<CS41) | (0<<CS40);
  TCNT4H=0x00;
  TCNT4L=0x00;
  ICR4H=0x6A;
  ICR4L=0x8F;
  OCR4AH=0x00;
  OCR4AL=0x00;
  OCR4BH=0x00;
  OCR4BL=0x00;
  OCR4CH=0x00;
  OCR4CL=0x00;
 
  OCR_(1,PT_min);
  OCR_(2,R_s);
  OCR_(3,E_s);
  OCR_(4,A_s);
}

As you see I want to generate 4 PWM pulse with timers.

Go Up