Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pic32 PWM?
19-11-2011, 01:02 AM,
#1
Pic32 PWM?
Which pins we have for Pwm channels? Do you have any demo program?
Reply
19-11-2011, 10:27 AM, (This post was last modified: 19-11-2011, 10:30 AM by pingotg.)
#2
RE: Pic32 PWM?
Looks like Chapter 16 of the PIC32 manuals may be what you want (I opened the various PDFs and searched for PWM). Read past the start, as it doesn't have to trigger from an external compare (I found it confusing).

I think there's an audio sample on the microchip site.

The DuinoMite boards all have sound output (and video), and MMBasic has software to create them, which might be helpful places to look.

(I realise these don't necessarily have to be PWM.)

On the -OTG it looks like pins 46,49,50,51 are the OCn ones but if you want quite low frequency PWM you could probably use any output and a timer interrupt routine to set it to 0/1 because these CPUs are quite fast Smile

John
Reply
19-11-2011, 06:19 PM,
#3
RE: Pic32 PWM?
Hi

You can use pin 0,1 and 2 as PWM output on Pinguino32 with the analogWrite instruction.

Jean-Pierre

(19-11-2011, 01:02 AM)Firatdede Wrote: Which pins we have for Pwm channels? Do you have any demo program?

Reply
27-11-2011, 09:35 AM,
#4
RE: Pic32 PWM?
How to set PWM.setfrequency? http://wiki.pinguino.cc/index.php/PWM.setfrequency It's empty..:/

Thanks
Reply
27-11-2011, 12:21 PM,
#5
RE: Pic32 PWM?
Hi,
You can take a look at examples/3.Analog/IRdetector.pde
Régis



(27-11-2011, 09:35 AM)Firatdede Wrote: How to set PWM.setfrequency? http://wiki.pinguino.cc/index.php/PWM.setfrequency It's empty..:/

Thanks

It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
27-11-2011, 06:09 PM,
#6
RE: Pic32 PWM?
Board: PIC32 Pinguino
Proc: 32MX440F256H
C:\pinguino32X\library\source\/user.c:54:2: error: 'PWM' undeclared (first use in this function)
C:\pinguino32X\library\source\/user.c:60:2: error: 'PWM' undeclared (first use in this function)
C:\pinguino32X\library\source\/user.c:108:2: error: too few arguments to function 'debug'
C:\pinguino32X\library\source\/user.c:116:2: error: 'PWM' undeclared (first use in this function)
C:\pinguino32X\library\source\/user.c:118:28: error: 'INT_MICROSEC' undeclared (first use in this function)
C:\pinguino32X\library\source\/user.c:120:29: error: 'INT_FALLING_EDGE' undeclared (first use in this function)
error while linking C:\pinguino32X\library\examples\3.Analog\IRdetector\ir-detector.o


It's getting bad..Undecided
Reply
18-04-2012, 12:36 AM,
#7
RE: Pic32 PWM?
Can anybody who has enough knowledge about what's happening here please answer the OP's last question about the error messages?

I face the exact same issue with an MX220 and rev. 305 of the IDE.

And could you supply the version of the IDE within "Help" -> "About" for future releases?

Generally, I would really like to contribute to increase the currently, well, low documentation level if I'd be able to find more information. However, most basic stuff (PWM, interrupts) is not really documented properly. In software engineering, its good practice that the person writing an interface/function is also responsible for its documentation. Can you please enforce this when accepting code? At the point where people have to know the PIC itself by heart to be able to do something of relevance with the Pinguino board, the usefulness of the project becomes questionable.

Thanks in advance,
/Markus
Reply
18-04-2012, 07:07 AM, (This post was last modified: 18-04-2012, 08:14 AM by moreno.)
#8
RE: Pic32 PWM?
Hi

With Pinguino 3.x 344 compiling ir-detector I have even other problems.

Code:
Board:    PIC32 Pinguino Micro
Proc:     32MX440F256H
D:\Pinguino32.3x.Bra\p32\include\pinguino\core/debug.c:21:9: error: macro names must be identifiers
D:\Pinguino32.3x.Bra\p32\include\pinguino\core/debug.c:28:9: error: macro names must be identifiers
D:\Pinguino32.3x.Bra\p32\include\pinguino\core/debug.c:31:9: error: macro names must be identifiers
D:\Pinguino32.3x.Bra\p32\include\pinguino\core/debug.c:34:9: error: macro names must be identifiers
D:\Pinguino32.3x.Bra\p32\include\pinguino\core/debug.c:37:9: error: macro names must be identifiers
D:\Pinguino32.3x.Bra\p32\include\pinguino\core/debug.c:45:9: error: macro names must be identifiers
D:\Pinguino32.3x.Bra\source\/user.c:28:2: error: 'PWM' undeclared (first use in this function)
D:\Pinguino32.3x.Bra\source\/user.c:33:2: error: 'PWM' undeclared (first use in this function)
D:\Pinguino32.3x.Bra\source\/user.c:78:2: error: too few arguments to function 'debug'
D:\Pinguino32.3x.Bra\source\/user.c:86:2: error: 'PWM' undeclared (first use in this function)
D:\Pinguino32.3x.Bra\source\/user.c:87:28: error: 'INT_MICROSEC' undeclared (first use in this function)
D:\Pinguino32.3x.Bra\source\/user.c:88:29: error: 'INT_FALLING_EDGE' undeclared (first use in this function)
error while linking D:\Pinguino32.3x.Bra\examples\03.Analog\IRdetector\ir-detector.o

in debug.c file there are strange ifdef definitions like
[code]
#ifdef (USBOTGDEBUG)
[/url]
I removed all the parentheses and now debug.c do not give more problems.
I attach the modified file.

But I think the biggest problems are in interrupt.c in the p32 version do not exist the definition of INT_MICROSEC and INT_FALLING_EDGE and are not defined all the Onxxxxx functions like OnTimerx OnCounter etc.


Bye Bye, Moreno


Attached Files
.c   debug.c (Size: 1.05 KB / Downloads: 3)
Reply
18-04-2012, 08:24 AM, (This post was last modified: 18-04-2012, 08:25 AM by moreno.)
#9
RE: Pic32 PWM?
Hi

I found the source of the problem related to
Code:
D:\Pinguino32.3x.Bra\source\/user.c:28:2: error: 'PWM' undeclared (first use in this function)
D:\Pinguino32.3x.Bra\source\/user.c:33:2: error: 'PWM' undeclared (first use in this function)

D:\Pinguino32.3x.Bra\source\/user.c:78:2: error: too few arguments to function 'debug'

The PWM function defined in PWM.PDL and PWM.PDL32 have different case.

The correct function name are:
PWM.setFrequency
PWM.setDutyCycle
PWM.setPercentDutyCycle

For the debug problem is necessary supply a parameter
Instead of Debug() is necessary use Debug("x");

Remain only the problem for missing OnTimer0 and OnChangePin0 for p32 board.


Bye Bye, Moreno
Reply
18-04-2012, 09:59 AM, (This post was last modified: 18-04-2012, 10:15 AM by regis.)
#10
RE: Pic32 PWM?
(18-04-2012, 08:24 AM)moreno Wrote: Remain only the problem for missing OnTimer0 and OnChangePin0 for p32 board.

These functions have not been yet adapted to 32-bit Pinguino ...
Any volunteer ?

In Debug Menu, if you choose USB CDC then debug() is the same as CDC.printf() function.
If you choose Serial then it's the same as Serial.printf().
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)