I'm at a loss here.
I can get the IF statement to work, but as soon as I add an else statement, it just always executes the else statement.
The seven segment code works fine, but i'm sure is super inefficient, but one thing at a time i guess.
in this case, the 7 segment is displaying the else case, even though i > 135. If i remove the else statement, the if statement executes properly.
I can get the IF statement to work, but as soon as I add an else statement, it just always executes the else statement.
The seven segment code works fine, but i'm sure is super inefficient, but one thing at a time i guess.
Code:
/**
Generated Main Source File
Company:
Microchip Technology Inc.
File Name:
main.c
Summary:
This is the main file generated using MPLAB(c) Code Configurator
Description:
This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information :
Product Revision : MPLAB(c) Code Configurator - 3.15.0
Device : PIC16F1574
Driver Version : 2.00
The generated drivers are tested against the following:
Compiler : XC8 1.35
MPLAB : MPLAB X 3.20
*/
/*
(c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this
software and any derivatives exclusively with Microchip products.
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
TERMS.
*/
#include "mcc_generated_files/mcc.h"
/*
Main application
*/
void main(void)
{
// initialize the device
SYSTEM_Initialize();
// When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
// Use the following macros to:
// Enable the Global Interrupts
//INTERRUPT_GlobalInterruptEnable();
// Enable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
while (1)
{
// Add your application code
unsigned int i;
for (i=1200; i>125; i-=10)
{
PWM1DCL = i;
PWM1DCH = (i >> 8);
PWM1LDCON = 0x80;
__delay_ms(10);
}
for (i=125; i>10; i-=10)
{
PWM1DCL = i;
PWM1LDCON = 0x80;
__delay_ms(10);
}
for (i=5; i>1; i--)
{
PWM1DCL = i;
PWM1LDCON = 0x80;
__delay_ms(25);
}
for (i = 1; i < 5; i++)
{
PWM1DCL = i;
PWM1LDCON = 0x80;
__delay_ms(25);
}
for (i = 10; i < 125; i+=10)
{
PWM1DCL = i;
PWM1LDCON = 0x80;
__delay_ms(10);
}
for (i = 135; i < 1200; i+=10)
{
PWM1DCL = i;
PWM1DCH = (i >> 8);
PWM1LDCON = 0x80;
__delay_ms(10);
}
if(i>135)
{
SEG7A_SetLow();
SEG7B_SetLow();
SEG7C_SetLow();
SEG7D_SetLow();
SEG7E_SetHigh();
SEG7F_SetLow();
SEG7G_SetLow();
}
else;
{
SEG7A_SetHigh();
SEG7B_SetLow();
SEG7C_SetLow();
SEG7D_SetHigh();
SEG7E_SetHigh();
SEG7F_SetHigh();
SEG7G_SetHigh();
}
}
}
/**
End of File
*/