Skip to content

Bardia-Afshar/AD9833-STM32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

AD9833-STM32

A Simple Library for AD9833 based on STM32

This is a library for AD9833 DDS Chip from Analog Devices.

For my project, I used STM32F030F4P6 and HAL libraries based on STM32CubeMX. I tried to write the library simple so as you can port it on other microcontrollers. It uses Software-Based SPI, so you do not need to configure SPI registers on your microcontroller. I tested it in IAR for ARM and Eclipse with GCC-ARM, and it worked fine. Moreover, I used FREQ0 and PHASE0 Register of AD9833. You can easily change it to FREQ1 and PHASE1 if you need it.

AD9833 DATASHEET

AD9833 Application Note

How to use

You have to allocate 3 GPIOs of your controller. In my case, I used PA5, PA6 and PA7, and I configured them as output in STM32CubeMX. After that, you have to define output pins in AD9833.h.

2020-05-19_143422 2020-05-19_143603

There are three functions to change the behavior of AD9833 that you can use :

void AD9833_Init(uint16_t Wave,float FRQ,float Phase);   // Initializing AD9833
void AD9833_SetWave(uint16_t Wave);                      // Sets Output Wave Type
void AD9833_SetWaveData(float Frequency,float Phase);    // Sets Wave Frequency & Phase

Note

Regarding the fact that this library uses a delay to execute software SPI, it can act differently with different microcontrollers. It depends on the master clock on your uC. If this library did not work for you, you have to change delay times in Write SPI function. You can do this with trial and error by adding some assembly nopes. Of course, you can use hardware SPI and add your functions to the library to avoid timing problems.

Test Results

Some Frequency Sweep test :) Sweep SIN SQR TRI

Releases

No releases published

Packages

No packages published

Languages