Embedded Signal Processing 

Project 5: Buterworth Filter, Ticker Interrupt-Driven Code, Digital Resistor


Overview

M.S. students randomized groups of two each week, never working with same student, unless otherwise directed by instructor.
Ph.D. students have option to choose their groups (all Ph.D. or mix), with or without randomization.


The objective of this project is to become familiar with:

NOTE: Use the Project Report Template and see below for minimum required data content your reports and demos.

IN NO CASE may code or files or data or pictures be exchanged between student groups, there is to be NO COPYING of group reports!
Also, each student must be able to independently answer any questions themselves during demos.
All students are expected to learn all aspects of every project.
Nevertheless, students are encouraged to collaborate (not copy) during the lab sessions.



Part 1, A Buterworth Lowpass Filter Using mbed Ticker Interrupt

zz
Fig. 1
zz
Fig. 2
#include "mbed.h"
DigitalOut gpo(D0);
DigitalOut led(LED_RED);
AnalogOut  dac0out(DAC0_OUT);
AnalogIn  adc0in(A0); //A0 = PTB2
//Serial pc(USBTX, USBRX);
Ticker timer1;

volatile float y=0,yold=0,x=0,xold=0;

void myDsp()// this dsp code will run off a timer interrupt
  {
    volatile uint32_t mask16=1<<16;
    volatile uint32_t dat1=(PTC->PDOR) | mask16; //set Port Data Output Register
    volatile uint32_t dat0=(PTC->PDOR) & (!mask16); //clear
    volatile uint16_t tpAdc0in=1,yout=0;
    extern volatile float y, yold,x,xold;
        (PTC->PDOR)=dat0; //clear
        (PTC->PDOR)=dat1; //set   ADD BREAKPOINT HERE
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat0; //clear
        tpAdc0in=adc0in.read_u16();
        x=(float)tpAdc0in;
        y=0.16412f*(x+xold)+0.67175f*yold;
        yold=y;
        xold=x;
        yout=(uint16_t)y;
        (PTC->PDOR)=dat0; //clear
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        (PTC->PDOR)=dat1; //set
        DAC0->DAT[0].DATL = (uint8_t)((uint16_t)(yout>>4)      & 0xFF);
        DAC0->DAT[0].DATH = (uint8_t)(((uint16_t)(yout>>4) >> 8) & 0x0F);
        (PTC->PDOR)=dat0; //clear
}

int main()
{
 
    if(1) {
        ADC0->SC3 &= ~ADC_SC3_AVGE_MASK;//disable averages
        ADC0->CFG1 &= ~ADC_CFG1_ADLPC_MASK;//high-power mode
        ADC0->CFG1 &= ~0x0063 ; //clears ADICLK and ADIV
        ADC0->CFG1 |= ADC_CFG1_ADIV(0); //divide clock 0=/1, 1=/2, 2=/4, 3=/8
         }

    DAC0->C0 = 0; DAC0->C1 = 0; //reset DAC state
    DAC0->C0 = DAC_C0_DACEN_MASK | DAC_C0_DACSWTRG_MASK| DAC_C0_DACRFS_MASK;

    extern volatile float y,yold,x,xold;
    timer1.attach(&myDsp,12.5e-6f); // calls the myDsp function every 12.5 microseconds
    uint32_t cntr=0;
    while (true) {
        cntr=cntr+1; //does nothing, jst waiting for timer to call DSP code
        if(cntr>1000000) cntr=0;
    }

}


z

Fig. 3


zz
Fig. 4
z
Fig. 5


zz
Fig. 6
z
Fig. 7
zz
Fig. 8



Part 2, Digital Resistor


Report Data



Report:


Copyright  2015-2016 T. Weldon

Freescale, Kinetis are registered trademarks of Freescale Semiconductor, Inc.   Texas Instruments, TI, C2000, and Code Composer Studio are a registered trademarks of Texas Instruments Incorporated.   Adafruit is a registered TradeMark of Limor Fried.  ARM, Cortex and Keil are registered trademarks of ARM Limited (or its subsidiaries).  Apple, Yosemite, Mac OS, iPhone, iPad, MacBook, Mac, iTunes, and Xcode are trademarks of Apple inc. All other product or service names are the property of their respective owners.  Arduino is a registered trademark of Arduino.