Pão de Queijo Development Board. This repo has all libraries from pqdb shield.
Pão de Queijo development board is a shield for add-on on any arduino compatible board.
This project presents the libraries to control the board peripherals using mbed framework. The libraries works as interfaces to keep the main code compatible with the examples from the book "Programação de sistemas embarcados". The peripherals on the board are presented on the folowing picture
The main objective of the project is to develop a low cost, easy to assemble board with a group of peripheral that allows one to start learning embedded systems. The board was routed on one side copper PCB to make easier to buid it yourself.
The source code for Arduino boards (wiring) can be found on: https://github.com/projetopqdb/PQDB-Arduino
The source code for freedom frdm KL05 board (using direct register access) can be found on: https://github.com/projetopqdb/PQDB-KL05Z
The source code from the board schematics and layout can be found on: https://github.com/projetopqdb/PQDB-Hardware
pwm.cpp
- Committer:
- rmaalmeida
- Date:
- 2017-10-03
- Revision:
- 6:3fb450ba1e95
- Parent:
- 3:6ca4d7dd8bea
File content as of revision 6:3fb450ba1e95:
#include "pwm.h" //#include "io.h" //#include "derivative.h" #include "mbed.h" PwmOut buzzer(D9); //liga o buzzer com uma frequ�ncia de som //duty cycle configurado em 50% void pwmBuzzer(unsigned int frequency){ //para prescaler = 1/1 (sem prescaler) if ((frequency>0) && (frequency < 40000)){ buzzer.period(1.0/frequency); buzzer.write(50); // period = 24000000/frequency; //TPM0_MOD = period; //TPM0_C0V = (period/2); } } //define uma frequ�ncia de trabalho void pwmFrequency(unsigned int frequency){ //para prescaler = 1/1 (sem prescaler) if ((frequency>0) && (frequency < 40000)){ buzzer.period(1.0/frequency); //buzzer.pulsewidth(0.5f/frequency); //TPM0_MOD = 24000000/frequency; } } //configura a sa�da como um valor de 0 � 100% void pwmDutyCycle(float percentage){ if ((percentage>=0) && (percentage <= 100)){ buzzer.write(percentage); //TPM0_MOD = (unsigned int)((percentage*TPM0_MOD)/100); } } void pwmInit(void){ buzzer.write(0); //Habilita as sa�das dos terminais // SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTA_MASK; //Habilita o clock para o perif�rico do PWM // SIM_SCGC6|=( SIM_SCGC6_TPM0_MASK | SIM_SCGC6_TPM1_MASK); //escolhe a fonte de clock do perif�rico como o oscilador principal do sistema // SIM_SOPT2 |= SIM_SOPT2_TPMSRC(1); // //configura o terminal D9 (portb 11) como uma sa�da do tipo PWM // PORTB_PCR11 = (0|PORT_PCR_MUX(2)); //configura o valor m�ximo para o contador de tempo // TPM0_MOD = 1000; //Configura timer para acioanr o PWM, ligando quando a comparar��o for verdadeira e desligando quando resetar o contador // TPM0_C0SC = TPM_CnSC_MSB_MASK | TPM_CnSC_ELSA_MASK; //configura o registro de contador para aumentar a cada incremento do timer, sem prescaler(1/1) // TPM0_SC = TPM_SC_CMOD(1) | TPM_SC_PS(0); }