thefloe Posted December 4, 2015 Report Share Posted December 4, 2015 Hi, First of all: I started working with my Papilio Pro again and I really like how things developed here! I really like the DesignLab and how easy it easy to connect things to your own blocks! Thanks. To verify some custom hardware connected to the board I need to create some square wave signal with some MHz. As neither analogWrite nor the PWM functions in the Timer class are working / present I tried writing to the registers directly (inspired by some forum post here) also does not toggle the PIN (WB12):#include "register.h" #define FREQUENCY 100000#define SW1 WB12void setup(){ pinMode(SW1, OUTPUT); pinModePPS(SW1, HIGH); outputPinForFunction(SW1, IOPIN_TIMER0_OC); TMR0CNT = 0; TMR0CMP = (CLK_FREQ / FREQUENCY) - 1; TMR0CTL = _BV(TCTLENA)|_BV(TCTLDIR)|_BV(TCTLCCM); TMR0PWMLOW(0) = 0; TMR0PWMHIGH(0) = 200; TMR0PWMCTL(0) = 1;} But for now the pin stays low... Quote Link to comment Share on other sites More sharing options...
Jack Gassett Posted December 4, 2015 Report Share Posted December 4, 2015 Hello, it looks like I need to make a tutorial for using PWM in DesignLab. I will try to make one this afternoon. Jack. Quote Link to comment Share on other sites More sharing options...
Jack Gassett Posted December 4, 2015 Report Share Posted December 4, 2015 In the meantime, there is a PWM in the Robot_Control_Library and an example of using it in the ColorCrossFader sketch in that library. Jack. Quote Link to comment Share on other sites More sharing options...
thefloe Posted December 4, 2015 Author Report Share Posted December 4, 2015 Hi Jack, Thank you! I will have a look and try it out Thanks Quote Link to comment Share on other sites More sharing options...
Jack Gassett Posted December 4, 2015 Report Share Posted December 4, 2015 Hello, I just recorded a quick walkthrough of using the PWM outputs from the Robot Control Library:https://youtu.be/mIiIna5G-NM We will turn this into a tutorial at the Learn Website soon. Quote Link to comment Share on other sites More sharing options...
thefloe Posted December 15, 2015 Author Report Share Posted December 15, 2015 Hi Jack, Thank you, got everything working for PWM (actually I just needed it to generate signals to verify other parts of the VHDL design). Tobias Quote Link to comment Share on other sites More sharing options...
Jack Gassett Posted December 15, 2015 Report Share Posted December 15, 2015 Excellent, I'm glad to hear that. By the way, there is a wave form generator under the Benchy section that you might find useful too. Jack. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.