Hi, I have this simple Arduino program thats put a PWM signal to port 9 of the Arduino. Checked with my RIGOL and the PWM is changed when I change the value of ppm.
#define PWM_A 9 /* Pin-9 on Arduino Board */ void setup() { Serial.begin(115200); int pwm = 200; /* duty 50% */ pinMode(PWM_A, OUTPUT); /* PWM speed is at 20 kHz */ /*Set the timers */ TCCR1A = 0b10100000; TCCR1B = 0b00010001; ICR1 = 400; /* value of 400 = 100 % ppm */ OCR1A = pwm; } void loop() { } Convert it to amForth. \ Address of Timer/Counter Arduino UNO \ Adresses are taken from device.py \ Partname ATmega328P $80 constant TCCR1A \ Timer/Counter1 Control Register A $81 constant TCCR1B \ Timer/Counter1 Control Register B $86 constant ICR1 \ Timer/Counter1 Input Capture Register $88 constant OCR1A \ Timer/Counter1 Output Compare Register A $8a constant OCR1B \ Timer/Counter1 Output Compare Register B PORTB 1 portpin: PWM_A \ alias for digital pin 9 (PB1) : PWM_init PWM_A pin_output \ Set pin 9 (PB1) to output %10100000 TCCR1A c! \ Store constant %00010001 TCCR1B c! \ Store constant &400 OCR1A c! \ Store constant ; : PWM_set ( value -- ) \ PWM is between 0..400 OCR1A c! \ Store into OCR1A ; > PWM_init > 200 PWM_set It will not work. What do I wrong. Thanks for any help Cheers, Jan _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel