//************************************************************************************
//**  
//**  Source name:   C:\Users\BenR\Desktop\FC_Tst.fcfx
//**  Title:         
//**  Description:   
//**  Device:        PIC16.33E.ECIO40P16
//**  
//**  Generated by:  Flowcode v7.2.0.5
//**  Date:          Thursday, March 09, 2017 09:44:14
//**  Users:         1
//**  Registered to: Dev User
//**  Licence key:   HJVC24
//**  
//**  
//**     NOT FOR COMMERCIAL USE
//**  
//**  http://www.matrixtsl.com
//**  
//************************************************************************************


#define MX_PIC16

#define MX_CAL_PIC16

#define MX_CLK_SPEED 140000000

#define FCP_NULL Unconnected_Port


#include <xc.h>
#include <math.h>
#include <stdlib.h>
#include "p33Exxxx.h"

#define MX_USB_33E

/*========================================================================*\
   Use :Include the type definitions
\*========================================================================*/
#include "F:\Flowcode 7\CAL\internals.c"





/*========================================================================*\
   Use :panel
       :Variable declarations
       :Macro function declarations
\*========================================================================*/
#define FCV_FALSE (0)
#define FCV_TRUE (1)
MX_GLOBAL MX_UINT16 FCV_C = (0x0);

void FCM_incCount();

/*========================================================================*\
   Use :Include the chip adaption layer
\*========================================================================*/
#include "F:\Flowcode 7\CAL\includes.c"


/*========================================================================*\
   Use :panel
       :Macro implementations
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
   Use :
\*=----------------------------------------------------------------------=*/
void FCM_incCount()
{

	// Calculation
	// Calculation:
	//  c = c + 1
	FCV_C = FCV_C + 1;

}



/*========================================================================*\
   Use :Main
\*========================================================================*/
int main()
{
ANSELB = 0;
ANSELC = 0;
ANSELD = 0;
ANSELE = 0;
ANSELG = 0;


	// Interrupt
	// Interrupt: Enable TMR5
	T5CON = ((T5CON & 0xfffd) | 0x8000);
	T5CON = ((T5CON & 0xff0f) | 0x0030);
	PR5=65536-1;
	IEC1bits.T5IE = 1;

	// Loop
	// Loop: While 1
	while (1)
	{

		// Output
		// Output: c -> PORTB_L
		FCP_SET(M, B, 0x00FF, 0, (FCV_C));

	}

	mainendloop: goto mainendloop;
	return 0;
}



/*========================================================================*\
   Use :Interrupt
\*========================================================================*/

	//Handler code for [TMR5]
	#ifndef MX_ISR_T5
	#define MX_ISR_T5
	void _ISR _T5Interrupt(void)
	{
		IFS1bits.T5IF = 0;
		FCM_incCount();
	}
	#else
	#warning "This interrupt has previously been enabled, so the macro <incCount> may never get called."
	#endif





