Hi, I wanted to ask that someone showed me a sample program to control the PWM in mini6410. Thanks for reply.
[Mini6410] Programming PWM
I've been using it to create alarm-type sounds on the mini6410. This is with a stock kernel from FriendlyArm - no custom kernels / kernel modules etc. I found that most of the online information was ... less than helpful ... because they all seemed to use devices / interfaces that aren't in the stock kernel. So, here's how I do it: ...stripped-down
Well, that didn't really work... Ok, I'll put the header and code files at: header: http://0x0000ff.com/src/buzzer/buzzerMgr.h source: http://0x0000ff.com/src/buzzer/buzzerMgr.cc Hopefully that'll work better...
Good night thank you all for your contributions. I want to know, how that program is made ​​this code? Does the program is for linux or windows? Is the program already has the libraries buzzer? Does the program brings more liberies?
Hi Jorge, If you mean the code I posted above, it's just a cut-and-paste from an application I'm writing. The code is written for QT under Linux, but you can just open /dev/pwm from any C program under Linux There is no library necessary - I don't know of a buzzer library, and I'd be happy to hear of one :) The code above is self-contained. It's not library code, I just compile it (as a C++ class) into my application. Cheers Simon
Hi simon if I want to try this code on my board or mini2440 mini6410, what file should I copy??. this code is made ​​for QT, but what is done in qt creator or some other program? Thank you very much.
Well, if you just want to use the buzzer, you don't need the whole class - that's just to allow the buzzer frequency to change on a background thread. In any 'C' program, you could write: #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #define PWM_IOCTL_SET_FREQ (1) #define PWM_IOCTL_STOP (0) int main(int argc, char **argv) { int fd = open("/dev/pwm", 0); ioctl(fd, PWM_IOCTL_SET_FREQ, 1000); sleep(2); // buzzer is now sounding ioctl(fd, PWM_IOCTL_STOP); close(fd); } ... and that's it. Change the '1000' to be a different number to get a different frequency. Personally I don't use QT creator, I just write the code in XCode on my mac. QTCreator was just too irritating for me... Simon
Hi simon ok, thank you very much, if I want to try this code, or I want to open my mini6410, how I can do? Do I have any particular operating system on my board? thanks
Hi Simon. Great info, thanks. I'm trying the same program on the mini2440, but the PWM don't stop (cross compiling from Linux to ARM, with arm-linux-gcc). It just ignores the "ioctl(fd, PWM_IOCTL_STOP);" line. If I put a stop command, followed by another PWM_IOCTL_SET_FREQ, it changes the beep frequency, but it still don't stop between the changes. Even after the "close(fd);" the program stops executing, but the buzzer don't stop sounding. Does someone else tried this under the 2440?
I have just confirmed on the Tiny6410 board I have here. Works perfectly on it. Yet, if someone else know the workaround on the Mini2440, I would be grateful.