Logxen Posted April 19, 2013 Report Share Posted April 19, 2013 Right now I am trying to get the timer0 pwm hooked up to the led on a papilio pro using pps. I can toggle the led with digitalWrite() in the sketch just fine, but I can't seem to get the timer and pwm to start up. Here's my sketch, I assume I've just misunderstood something in the zpuino spec sheet. I'm not even sure if my problem is with the timer or with pps. #define FREQUENCY 100000void setup(){ pinMode(49, OUTPUT); pinModePPS(49, HIGH); outputPinForFunction(49, 1);// digitalWrite(49, HIGH); TMR0CNT = 0; TMR0CMP = (CLK_FREQ / FREQUENCY) - 1; TMR0CTL = _BV(TCTLENA)|_BV(TCTLDIR)|_BV(TCTLCCM); TMR0PWMLOW(0) = 0; TMR0PWMHIGH(0) = 400; TMR0PWMCTL(0) = 1;}int v = 0;int d = 1;void loop(){ v += d; if(v >= 900) d = -1; else if(v <= 0) d = 1; TMR0PWMHIGH(0) = v; delay(10);}Thanks in advance! Link to comment Share on other sites More sharing options...
alvieboy Posted April 22, 2013 Report Share Posted April 22, 2013 Looks good... If you comment out the DigitalWrite(), does it change ? It should not, as it's being mapped to PPS. Link to comment Share on other sites More sharing options...
Logxen Posted April 22, 2013 Author Report Share Posted April 22, 2013 The digitalWrite works normally. If I comment it out like in the example there the led is off, if I uncomment it the led will turn on and stay on. Link to comment Share on other sites More sharing options...
alvieboy Posted April 23, 2013 Report Share Posted April 23, 2013 So PPS is not working for your pin.... because with pinModePPS(HIGH) the GPIO is disconnected from the pin. Which bitfile are you using ? Link to comment Share on other sites More sharing options...
Logxen Posted April 24, 2013 Author Report Share Posted April 24, 2013 Well, that's good to know. I've been using the retrocade bitstream as it seemed the most up-to-date with papilio pro stuff. Link to comment Share on other sites More sharing options...
alvieboy Posted April 24, 2013 Report Share Posted April 24, 2013 Retrocade... it should work. Can you try remapping it to wing A or wing B ? Link to comment Share on other sites More sharing options...
Logxen Posted April 24, 2013 Author Report Share Posted April 24, 2013 Yeah that seems like the logical next step... I'll try actually wiring an led up to one of the wings and see what happens next chance I get. Link to comment Share on other sites More sharing options...
alvieboy Posted April 25, 2013 Report Share Posted April 25, 2013 Wait... you're using the LED pin, right ? That pin is not PPS'able, only the wing pins are. Link to comment Share on other sites More sharing options...
Logxen Posted April 27, 2013 Author Report Share Posted April 27, 2013 well that would certainly explain it then. when I read the source it appeared to be hooked up based on my limited understanding of the hdl... thanks for clearing that up. Link to comment Share on other sites More sharing options...
alvieboy Posted April 29, 2013 Report Share Posted April 29, 2013 Although nice to have PPS on the LED pin, it has very limited functionality compared to the amount of resources needed to do it... No need to redirect audio output to the LED, for example, right ? Best,Alvie Link to comment Share on other sites More sharing options...
Logxen Posted May 3, 2013 Author Report Share Posted May 3, 2013 Yay! Finally got my button/led wing today and everything works fine. Thanks Alvie. Link to comment Share on other sites More sharing options...
alvieboy Posted May 4, 2013 Report Share Posted May 4, 2013 Excellent Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.