Dependencies:   mbed

Committer:
bcis93
Date:
Fri Oct 04 22:03:30 2019 +0000
Revision:
1:9fa7cc80f1a7
Parent:
0:4fb921928934
compiled;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nmaududi 0:4fb921928934 1 /**----------------------------------------------------------------------------
nmaududi 0:4fb921928934 2 *
nmaududi 0:4fb921928934 3 * \file frequency_detector.cpp
nmaududi 0:4fb921928934 4 -- --
nmaududi 0:4fb921928934 5 -- ECEN 5803 Mastering Embedded System Architecture --
nmaududi 0:4fb921928934 6 -- Project 1 Module 4 --
nmaududi 0:4fb921928934 7 -- Microcontroller Firmware --
nmaududi 0:4fb921928934 8 -- frequency_detector.cpp --
nmaududi 0:4fb921928934 9 -- --
nmaududi 0:4fb921928934 10 -------------------------------------------------------------------------------
nmaududi 0:4fb921928934 11 --
nmaududi 0:4fb921928934 12 -- Designed for: University of Colorado at Boulder
nmaududi 0:4fb921928934 13 --
nmaududi 0:4fb921928934 14 --
nmaududi 0:4fb921928934 15 -- Designed by: Tim Scherr
nmaududi 0:4fb921928934 16 -- Revised by: Naved Maududi and Bryan Cisneros
nmaududi 0:4fb921928934 17 --
nmaududi 0:4fb921928934 18 -- Version: 2.1
nmaududi 0:4fb921928934 19 -- Date of current revision: 2017-09-25
nmaududi 0:4fb921928934 20 -- Target Microcontroller: Freescale MKL25ZVMT4
nmaududi 0:4fb921928934 21 -- Tools used: ARM mbed compiler
nmaududi 0:4fb921928934 22 -- ARM mbed SDK
nmaududi 0:4fb921928934 23 -- Freescale FRDM-KL25Z Freedom Board
nmaududi 0:4fb921928934 24 --
nmaududi 0:4fb921928934 25 --
nmaududi 0:4fb921928934 26 Functional Description:
nmaududi 0:4fb921928934 27 This file contains code that takes in quasi-sine wave ADC inputs from the flow meter
nmaududi 0:4fb921928934 28 From the ADC inputs, it calculates the frequency of that sine wave. The frequency is
nmaududi 0:4fb921928934 29 important in determining the flow rate and velocity for the flowmeter that are outputed
nmaududi 0:4fb921928934 30 to the display.
nmaududi 0:4fb921928934 31 --
nmaududi 0:4fb921928934 32 -- Copyright (c) 2015 Tim Scherr All rights reserved.
nmaududi 0:4fb921928934 33 */
nmaududi 0:4fb921928934 34
nmaududi 0:4fb921928934 35
nmaududi 0:4fb921928934 36 #include "shared.h"
nmaududi 0:4fb921928934 37 #include "MKL25Z4.h"
nmaududi 0:4fb921928934 38 #define SPI_bit_length 16 // bit length for the spi port
nmaududi 0:4fb921928934 39 #define SPI_mode 0 // clock is set to trigger at high and in phase
nmaududi 0:4fb921928934 40
nmaududi 0:4fb921928934 41
nmaududi 0:4fb921928934 42
nmaududi 0:4fb921928934 43 /**********************/
nmaududi 0:4fb921928934 44
nmaududi 0:4fb921928934 45 PinName const SPI_MOSI = PTC6; // channel 0 (PTB0) to A/D pin VREFL
nmaududi 0:4fb921928934 46 PinName const SPI_MISO = PTC7; // channel 1 (PTB1) to J10_4 a virtual vortex frequency input,
nmaududi 0:4fb921928934 47 PinName const SPI_SCK = PTC5; // channel 2 (PTB2) to an actual internal TempSensor
nmaududi 0:4fb921928934 48
nmaududi 0:4fb921928934 49
nmaududi 0:4fb921928934 50 void LCD_Display(void){
nmaududi 0:4fb921928934 51
nmaududi 0:4fb921928934 52 SPI LCD(SPI_MOSI, SPI_MISO, SPI_SCK);
nmaududi 0:4fb921928934 53 LCD.lock(); // Acquire exclusive access to this SPI bus.
nmaududi 0:4fb921928934 54 LCD.format(SPI_bit_length, SPI_mode); // select correct mode and bits to transfer to the LDC monitor
nmaududi 0:4fb921928934 55 LCD.write(flow); // write the value of flow to slave device, which is the peripheral LCD display
nmaududi 0:4fb921928934 56 LCD.write(freq_value); // write the value of frequency to slave device, which is the peripheral LCD display
nmaududi 0:4fb921928934 57 LCD.write(temperature); // write the value of temperature to slave device, which is the peripheral LCD display
nmaududi 0:4fb921928934 58 }
nmaududi 0:4fb921928934 59
nmaududi 0:4fb921928934 60