NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/* --COPYRIGHT--,BSD_EX
* Copyright (c) 2013, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*******************************************************************************
*
* MSP432 CODE EXAMPLE DISCLAIMER
*
* MSP432 code examples are self-contained low-level programs that typically
* demonstrate a single peripheral function or device feature in a highly
* concise manner. For this the code may rely on the device's power-on default
* register values and settings such as the clock configuration and care must
* be taken when combining code from several examples to avoid potential side
* effects. Also see http://www.ti.com/tool/mspdriverlib for an API functional
* library & https://dev.ti.com/pinmux/ for a GUI approach to peripheral configuration.
*
* --/COPYRIGHT--*/
//***************************************************************************************
// MSP432P401 Demo - Timer0_A3 Capture of ACLK
//
// Description; Capture a number of periods of the ACLK clock and store them in an array.
// When the set number of periods is captured the program is trapped and the LED on
// P1.0 is toggled. At this point halt the program execution read out the values using
// the debugger.
//
// Ensure to connect ACLK out (P4.2) to TA0.CCI2A (P2.5) with a jumper.
//
// ACLK = REFOCLK = 32kHz, MCLK = SMCLK = default DCODIV = 3MHz.
//
// MSP432P401
// -----------------
// /|| |
// | | P2.5|<-- TA0.CCI2A
// --|RST | |
// | P4.2|--> ACLK
// | |
// | P1.0|-->LED
//
//
// William Goh
// Texas Instruments Inc.
// June 2016 (updated) | June 2014 (created)
// Built with CCSv6.1, IAR, Keil, GCC
//***************************************************************************************
#include "msp.h"
#include <stdint.h>
#include <Lab4_Part2.h>
int count = 0;
int result = 0;
int sec0 = 0;
int init = 0;
int diff = 0;

volatile int sec1 = 0;
volatile int sec2 = 0;
volatile int sec3 = 0;
volatile int sec4 = 0;


int main(void)
{
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // Stop watchdog timer

P4->DIR = ALLOUTPINS; //configure all output pins

// Configure GPIO
P2->DIR = 0x00; //2.4 as input
P2->SEL0 = BIT4; // SEL0 = 1
P2->SEL1 = 0x00; // SEL1 = 0

P2->DIR = 0x00; // 2.5 as input
P2->SEL0 = BIT5; // SEL0 = 1
P2->SEL1 = 0x00; // SEL1 = 0


TIMER_A0->CCTL[1] = TIMER_A_CCTLN_CM_1 | // Capture rising edge,
TIMER_A_CCTLN_CCIS_0 | // Use CCI1A=ACLK,
TIMER_A_CCTLN_CCIE | // Enable capture interrupt
TIMER_A_CCTLN_CAP | // Enable capture mode,
TIMER_A_CCTLN_SCS; // Synchronous capture

TIMER_A0->CCTL[2] = TIMER_A_CCTLN_CM_1 | // Capture rising edge,
TIMER_A_CCTLN_CCIS_0 | // Use CCI2A=ACLK,
TIMER_A_CCTLN_CCIE | // Enable capture interrupt
TIMER_A_CCTLN_CAP | // Enable capture mode,
TIMER_A_CCTLN_SCS; // Synchronous capture

TIMER_A0->CTL |= TIMER_A_CTL_TASSEL_1 | // Use ACLK as clock source,
TIMER_A_CTL_MC_2 | // Start timer in continuous mode
TIMER_A_CTL_CLR | // clear TA0R
TIMER_A_CTL_ID_3;

TIMER_A0->CCTL[1] &= ~(TIMER_A_CCTLN_CCIFG);
TIMER_A0->CCTL[2] &= ~(TIMER_A_CCTLN_CCIFG);

NVIC_EnableIRQ(TA0_N_IRQn); //Enable timer0 interrupt
__enable_irq(); // Enable global interrupt

while(1)
{

INIT_LCD(); //initializes the LCD
CLEAR_LCD(); //clears anything on the LCD
sec0 = 8 * result / 320;
sec1 = (sec0 / 100) % 10;

sec2 = (sec0 / 10) % 10;
sec3 = sec0 % 10;
if(sec1 >= 9)
{
sec4 = 0x31;
sec1 = 0;

} //endif
else
sec4 = 0x30;

OUTPUT_CHAR(sec4);
OUTPUT_CHAR(0x30 + sec1);
OUTPUT_CHAR('.'); //displays character .
OUTPUT_CHAR(0x30 + sec2);
OUTPUT_CHAR(0x30 + sec3);
}


} // end main

// Timer A0 interrupt service routine
void TA0_N_IRQHandler(void)
{
count++;
if (count == 1)
{
TA0CTL |= TACLR;
TIMER_A0->CCTL[1] &= ~(TIMER_A_CCTLN_CCIFG);
//sec4=0;

}
if (count == 2)
{
result = TA0CCR2;
count = 0;
TIMER_A0->CCTL[2] &= ~(TIMER_A_CCTLN_CCIFG);

}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.