#pragma vector=PORT1_VECTOR
__interrupt void P1_ISR(void) {
if(UART_COM_PORT_IFG & MODULATOR_DIGITAL_IN) { // isr caused by MODULATOR_DIGITAL_IN ?
if(UART_COM_PORT_IES & MODULATOR_DIGITAL_IN) {// caused by high-low transmission ?
BitFreq = _1850HzBitFreq; // load logical 0 value into modulation register
LED_PORT_OUT &= ~DATA_LED; // LED on
UART_COM_PORT_IES &= ~MODULATOR_DIGITAL_IN;// change pin isr edge sensivity
} else {
BitFreq = _1650HzBitFreq; // load logical 1 value into modulation register
LED_PORT_OUT |= DATA_LED; / / LED off
UART_COM_PORT_IES |= MODULATOR_DIGITAL_IN; // change pin isr edge sensivity
}
UART_COM_PORT_IFG &= ~MODULATOR_DIGITAL_IN; // clear interrupt flag
} else {
UART_COM_PORT_IFG = 0;
}
}
pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A1(void) {
static signed int Prev_negEgdeCapture = 0;
static signed int Prev_posEgdeCapture = 0;
static unsigned char EdgeCounter = 0;
signed int CCR1_Capture;
signed int Capture_Diff;
// CCR1 interrupt handler
case 2:
CCR1_Capture = TACCR1;
if(ModemStatusReg & POSITIVE_EDGE) {
Capture_Diff = CCR1_Capture - Prev_posEgdeCapture;
Prev_posEgdeCapture = CCR1_Capture;
ModemStatusReg &= ~POSITIVE_EDGE;
} else {
Capture_Diff = CCR1_Capture - v_negEgdeCapture;
Prev_negEgdeCapture = CCR1_Capture;
ModemStatusReg |= POSITIVE_EDGE;
}
if(Capture_Diff > RX_FREQ_CHN1_SPACE-CHN1_MARGIN && Capture_Diff < RX_FREQ_CHN1_SPACE+CHN1_MARGIN) {
if(HandshakeStateMachine == DetectOnes)
EdgeCounter = 0;
// 0 detected
zeros++;
ModemStatusReg |= OFF_HOOK;
} else if(Capture_Diff > RX_FREQ_CHN1_MARK-CHN1_MARGIN && Capture_Diff < RX_FREQ_CHN1_MARK+CHN1_MARGIN) {
// handle detection of binary ones during negotiation handshake
if(HandshakeStateMachine == DetectOnes) { // are we performing the negotiation handshake?
EdgeCounter++; // increment counter
if(EdgeCounter == DetectTime_Chn1) { // sufficient edges detected?
HandshakeStateMachine = OnesDetected; // change to next negotiation handshake state
}
}
// 1 detected
ones++;
ModemStatusReg |= OFF_HOOK;
}
if( zeros>=6 && ModemStateMachine == DataMode && !(ModemStatusReg & STARTBIT)) {
ModemStatusReg |= STARTBIT; // startbit detected
BitCounter = 0;
zeros = 0; // reset counters
ones = 0;
UART_COM_PORT_OUT &= ~DEMODULATOR_DIGITAL_OUT; // show startbit to UART
LED_PORT_OUT &= ~DATA_LED;
TACCTL0 = CCIE;
TACCR0 = CCR1_Capture + BAUDRATE;
}
break;
}
#pragma vector=TIMERA0_VECTOR
__interrupt void TA_CCR0_ISR(void) {
static unsigned int HandshakeCounter = 0;
// DataMode
if((ModemStatusReg & STARTBIT) && ModemStateMachine == DataMode) {
BitCounter++;
if(BitCounter == 9) { // processed one byte ?
TACCTL0 = 0; // stop bit detection trigger
ModemStatusReg &= ~STARTBIT;
UART_COM_PORT_OUT |= DEMODULATOR_DIGITAL_OUT; // show stopbit to UART
LED_PORT_OUT |= DATA_LED; // LED off
} else {
if(ones >= zeros) {
UART_COM_PORT_OUT |= DEMODULATOR_DIGITAL_OUT; // show 1 to UART
LED_PORT_OUT |= DATA_LED; // LED off
} else {
UART_COM_PORT_OUT &= ~DEMODULATOR_DIGITAL_OUT;// show 0 to UART
LED_PORT_OUT &= ~DATA_LED; // LED on
}
}
zeros = 0;
ones = 0;
}
.......
}
Pin P1.2 successfully converts the original frequency signal into a binary digital signal, and then directly connects pin P1.2 to the receiving pin of serial port 0, so that we can directly read the received data in the serial port buffer. The graph after signal conversion is as follows:
Previous article:Design of low power portable thermometer based on MSP430
Next article:MSP430 PWM
Recommended ReadingLatest update time:2024-11-16 18:01
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- GigaDevice GD32 MCU Design Competition Selected Works Album (Limited Time Free Points Download)
- Share the production of a wireless remote control car
- Review of the 2019 National Electronic Design Competition - The small plane I made
- 【GD32F310G-START】USART indefinite length reception
- Discussion on simple polymer lithium battery charging and discharging circuit. Please give me your valuable advice.
- Difference between TMS320C6713 and TMS320C6713B
- [TI recommended course] #DC/DC switching regulator packaging innovation#
- Renesas CPK-RA2L1 development board first step development environment construction
- Working principle of LM393 voltage comparator
- The difference between MCU interface and RGB interface