Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dsplib.h>
- #define NUM_SAMPLES 5000
- #define krok 137
- int pila[NUM_SAMPLES];
- int prostokatny[NUM_SAMPLES];
- int trojkatny[NUM_SAMPLES];
- void saw(int* tablica, unsigned int dl_tablicy, unsigned int step){
- int amplituda = 0;
- int i;
- tablica[0] = 0;
- for(i = 1; i < dl_tablicy; i++){
- amplituda = amplituda + step;
- tablica[i] = amplituda;
- }
- }
- void rect(int* tablica_prost, unsigned int dl_tablicy, unsigned int step, int prog){
- int amplituda = 0;
- int i;
- for(i = 1; i < dl_tablicy; i++){
- if(amplituda < prog){
- tablica_prost[i] = 32767;
- }
- else{
- tablica_prost[i] = -32768;
- }
- amplituda = amplituda + step;
- }
- }
- void tri(int* tablica_tri, unsigned int dl_tablicy, unsigned int step){
- signed int amplituda = 0;
- signed int bezwzgledna = 0;
- int i;
- tablica_tri[0] = 0;
- for(i = 1; i < dl_tablicy; i++){
- amplituda = amplituda + step;
- bezwzgledna = amplituda < 0 ? -amplituda : amplituda;
- tablica_tri[i] = ((bezwzgledna<<1) - 32767);
- }
- }
- void main(void) {
- //saw(pila, NUM_SAMPLES, krok);
- //rect(prostokatny, NUM_SAMPLES, krok, 0);
- tri(trojkatny, NUM_SAMPLES, krok);
- while (1); // do not exit
- }
Advertisement
Add Comment
Please, Sign In to add comment