Sie sind auf Seite 1von 31

//*******************************************************************************

*****
//**
//** Source name: C:\Users\EE49~1\AppData\Local\Temp\7zOCB3BB65E\StepperMotor.fcfx
//** Title:
//** Description:
//** Device:
AVR.ATMEGA.ATMEGA2560
//**
//** Generated by: Flowcode v6.1.1.0
//** Date:
Wednesday, May 20, 2015 00:25:15
//** Users:
0
//** Registered to: 28322117
//** Licence key: J88QJ5
//**
//**
//** ???? ??? ????????? ????? !
//**
//** http://www.matrixtsl.com
//**
//*******************************************************************************
*****
#define MX_AVR
#define MX_CAL_AVR
#define MX_CLK_SPEED 8000000
#define FCP_NULL Unconnected_Port
#define MX_UART_ID
#define MX_UART_UCSRC
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <avr\io.h>
#include <avr\interrupt.h>
#include <avr\eeprom.h>
#include <avr\wdt.h>
//Configuration Start
//Configuration End
/*=====================================================================
===*\
Use :????????????? ???? ?????? ??? ???????
\*=====================================================================
===*/
#include "C:\Program Files (x86)\Flowcode 6\CAL\internals.c"
MX_UINT8 FCLV_LOOP1;
MX_UINT8 FCLV_LOOP2;

/*=====================================================================
===*\
Use :panel
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
#define FCV_FALSE (0)
#define FCV_TRUE (1)
/*=====================================================================
===*\
Use :lut
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
#define FCVsz_00fb1_lut__FLOATFIXEDLIST 1
#define FCVsz_00fb1_lut__INTLIST 8
#define FCVsz_00fb1_lut__FLOATLIST 1
#define FCVsz_00fb1_lut__INTFIXEDLIST 1
#define FCD_00fb1_lut__INTLIST(ix) FCD_00fb1_lut__INTLIST_LUT[ix]
ROMARRAY_(MX_UINT8) FCD_00fb1_lut__INTLIST_LUT ROMARRAY_E =
{
// Property added elements
// Dynamically added elements
6, 14, 10, 11, 9, 13, 5, 7
};
/*=====================================================================
===*\
Use :stepper_base
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
MX_GLOBAL MX_UINT8 FCV_02411_stepper_base__ENABLED = (0x0);
MX_GLOBAL MX_UINT8 FCV_02411_stepper_base__STEP_PHASE = (0x0);
MX_GLOBAL MX_UINT32 FCV_02411_stepper_base__TARGET_START_POS;
MX_GLOBAL MX_FLOAT FCV_02411_stepper_base__TOTAL_Z = (0.0);
MX_GLOBAL MX_FLOAT FCV_02411_stepper_base__TOTAL_Y = (0.0);
MX_GLOBAL MX_FLOAT FCV_02411_stepper_base__TOTAL_X = (0.0);
MX_GLOBAL MX_UINT32 FCV_02411_stepper_base__TARGET_HANDLE = (0x0);
MX_GLOBAL MX_FLOAT FCV_02411_stepper_base__TOTAL_ANGLE;
MX_GLOBAL MX_UINT8 FCV_02411_stepper_base__DUMMY;
MX_GLOBAL MX_UINT8 FCV_02411_stepper_base__ROLLOVER = 8;
MX_GLOBAL MX_UINT32 FCV_02411_stepper_base__MOVING_START_POS;
void FCD_02411_stepper_base__IncrementStep();

void FCD_02411_stepper_base__DecrementStep();
void FCD_02411_stepper_base__EnableMotor();
void FCD_02411_stepper_base__Output_Step(MX_UINT8 FCL_PATTERN);
void FCD_02411_stepper_base__DisableMotor();
/*=====================================================================
===*\
Use :stepper_generic1
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
#define FCD_001a1_stepper_generic1__IncrementStep FCD_02411_stepper_base__IncrementStep
#define FCD_001a1_stepper_generic1__DecrementStep
FCD_02411_stepper_base__DecrementStep
#define FCD_001a1_stepper_generic1__EnableMotor FCD_02411_stepper_base__EnableMotor
#define FCD_001a1_stepper_generic1__DisableMotor FCD_02411_stepper_base__DisableMotor
/*=====================================================================
===*\
Use :????????????? ?? ?????? ??????????? ??? ????????????????
\*=====================================================================
===*/
#include "C:\Program Files (x86)\Flowcode 6\CAL\includes.c"
/*=====================================================================
===*\
Use :lut
:????????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :stepper_base
:????????? ????????????
\*=====================================================================
===*/
/*=----------------------------------------------------------------------=*\
Use :Move the motor forward by one step.
\*=----------------------------------------------------------------------=*/
void FCD_02411_stepper_base__IncrementStep()
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_VALUE;
if (FCV_02411_stepper_base__ENABLED)
{
FCV_02411_stepper_base__STEP_PHASE = (FCV_02411_stepper_base__STEP_PHASE +

1);
if (FCV_02411_stepper_base__STEP_PHASE >= FCV_02411_stepper_base__ROLLOVER)
{
FCV_02411_stepper_base__STEP_PHASE = 0;
// } else {
}
FCL_VALUE = FCD_00fb1_lut__INTLIST(FCV_02411_stepper_base__STEP_PHASE);
FCD_02411_stepper_base__Output_Step(FCL_VALUE);
// } else {
}
}
/*=----------------------------------------------------------------------=*\
Use :Move the motor backwards by one step.
\*=----------------------------------------------------------------------=*/
void FCD_02411_stepper_base__DecrementStep()
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_VALUE;
if (FCV_02411_stepper_base__ENABLED)
{
if (FCV_02411_stepper_base__STEP_PHASE == 0)
{
FCV_02411_stepper_base__STEP_PHASE = FCV_02411_stepper_base__ROLLOVER;
// } else {
}
FCV_02411_stepper_base__STEP_PHASE = (FCV_02411_stepper_base__STEP_PHASE 1);
FCL_VALUE = FCD_00fb1_lut__INTLIST(FCV_02411_stepper_base__STEP_PHASE);
FCD_02411_stepper_base__Output_Step(FCL_VALUE);
// } else {
}

}
/*=----------------------------------------------------------------------=*\
Use :Turn on the motor. This must be done before it will respond to any other macros.
\*=----------------------------------------------------------------------=*/
void FCD_02411_stepper_base__EnableMotor()
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_VALUE = (0x0);
FCV_02411_stepper_base__ENABLED = 1;
FCL_VALUE = FCD_00fb1_lut__INTLIST(FCV_02411_stepper_base__STEP_PHASE);
if (FCL_VALUE & 0x01)
{
FCP_SET(B, A, 0x1, 0x0, 1);
} else {
FCP_SET(B, A, 0x1, 0x0, 0);
}
if (FCL_VALUE & 0x02)
{
FCP_SET(B, A, 0x2, 0x1, 1);
} else {
FCP_SET(B, A, 0x2, 0x1, 0);
}
if (FCL_VALUE & 0x04)
{
FCP_SET(B, A, 0x4, 0x2, 1);
} else {
FCP_SET(B, A, 0x4, 0x2, 0);
}
if (FCL_VALUE & 0x08)
{

FCP_SET(B, A, 0x8, 0x3, 1);


} else {
FCP_SET(B, A, 0x8, 0x3, 0);
}
}
/*=----------------------------------------------------------------------=*\
Use :?????????? ???????????? Output_Step:
: Pattern : MX_UINT8
\*=----------------------------------------------------------------------=*/
void FCD_02411_stepper_base__Output_Step(MX_UINT8 FCL_PATTERN)
{
if (FCL_PATTERN & 0x01)
{
FCP_SET(B, A, 0x1, 0x0, 1);
} else {
FCP_SET(B, A, 0x1, 0x0, 0);
}
if (FCL_PATTERN & 0x02)
{
FCP_SET(B, A, 0x2, 0x1, 1);
} else {
FCP_SET(B, A, 0x2, 0x1, 0);
}
if (FCL_PATTERN & 0x04)
{
FCP_SET(B, A, 0x4, 0x2, 1);
} else {
FCP_SET(B, A, 0x4, 0x2, 0);
}
if (FCL_PATTERN & 0x08)
{

FCP_SET(B, A, 0x8, 0x3, 1);


} else {
FCP_SET(B, A, 0x8, 0x3, 0);
}
}
/*=----------------------------------------------------------------------=*\
Use :Turn off the motor. It will no longer respond to any other macros.
\*=----------------------------------------------------------------------=*/
void FCD_02411_stepper_base__DisableMotor()
{
FCV_02411_stepper_base__ENABLED = 0;
FCP_SET(B, A, 0x1, 0x0, 0);
FCP_SET(B, A, 0x2, 0x1, 0);
FCP_SET(B, A, 0x4, 0x2, 0);
FCP_SET(B, A, 0x8, 0x3, 0);
FCV_02411_stepper_base__DUMMY = FCP_GET(B, A, 0x1, 0x0);
FCV_02411_stepper_base__DUMMY = FCP_GET(B, A, 0x2, 0x1);
FCV_02411_stepper_base__DUMMY = FCP_GET(B, A, 0x4, 0x2);
FCV_02411_stepper_base__DUMMY = FCP_GET(B, A, 0x8, 0x3);
}
/*=====================================================================
===*\
Use :stepper_generic1
:????????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :panel
:????????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :????????
\*=====================================================================
===*/

int main()
{
MCUCR=0x00;
MCUSR=0x00;
wdt_disable();
EIMSK=0x00;
// Call Component Macro
// ????? ???????????? ???????????: stepper_generic1::EnableMotor()
FCD_001a1_stepper_generic1__EnableMotor();
// Loop
// ??????: While 1
while (1)
{
// Loop
// ??????: ?????? 255 ?????
for (FCLV_LOOP1=0; (FCLV_LOOP1)<(255); (FCLV_LOOP1)++)
{
// Call Component Macro
// ????? ???????????? ???????????: stepper_generic1::IncrementStep()
FCD_001a1_stepper_generic1__IncrementStep();
// Delay
// ???????????: 10 ms
FCI_DELAYBYTE_MS(10);
}
// Loop
// ??????: ?????? 50 ?????
for (FCLV_LOOP2=0; (FCLV_LOOP2)<(50); (FCLV_LOOP2)++)
{
// Call Component Macro
// ????? ???????????? ???????????: stepper_generic1::DecrementStep()
FCD_001a1_stepper_generic1__DecrementStep();
// Delay
// ???????????: 50 ms
FCI_DELAYBYTE_MS(50);
}
}

mainendloop: goto mainendloop;


}

/*=====================================================================
===*\
Use :???????
\*=====================================================================
===*/

//*******************************************************************************
*****
//**
//** Source name: C:\Users\EE49~1\AppData\Local\Temp\7zOCB3D5A2E\Frequency
Counter.fcfx
//** Title:
//** Description:
//** Device:
AVR.ATMEGA.ATMEGA2560
//**
//** Generated by: Flowcode v6.1.1.0
//** Date:
Wednesday, May 20, 2015 00:27:26
//** Users:
0
//** Registered to: 28322117
//** Licence key: J88QJ5
//**
//**
//** ???? ??? ????????? ????? !
//**
//** http://www.matrixtsl.com
//**
//*******************************************************************************
*****
#define MX_AVR
#define MX_CAL_AVR
#define MX_CLK_SPEED 8000000
#define FCP_NULL Unconnected_Port
#define MX_UART_ID
#define MX_UART_UCSRC
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <avr\io.h>
#include <avr\interrupt.h>

#include <avr\eeprom.h>
#include <avr\wdt.h>
//Configuration Start
//Configuration End
/*=====================================================================
===*\
Use :????????????? ???? ?????? ??? ???????
\*=====================================================================
===*/
#include "C:\Program Files (x86)\Flowcode 6\CAL\internals.c"

/*=====================================================================
===*\
Use :panel
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
#define FCV_FALSE (0)
#define FCV_TRUE (1)
MX_GLOBAL MX_UINT8 FCV_COUNT = (0x0);
MX_GLOBAL MX_UINT8 FCV_IN = (0x0);
MX_GLOBAL MX_SINT16 FCV_FREQ = (0);
MX_GLOBAL MX_UINT8 FCV_UPDATE_DISPLAY = (0x0);
MX_GLOBAL MX_SINT16 FCV_DISPLAY_FREQ = (0);
void FCM_TMR_INT();
void FCM_Read_input();
/*=====================================================================
===*\
Use :ButtonCtrl
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :switch_base
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
MX_UINT8 FCD_05261_switch_base__ReadState();
void FCD_05261_switch_base__WaitUntilHigh();
void FCD_05261_switch_base__WaitUntilLow();

/*=====================================================================
===*\
Use :ctrl_lcd
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :LCD
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
void FCD_04071_LCD__Clear();
void FCD_04071_LCD__PrintString(MX_CHAR *FCL_TEXT, MX_UINT16 FCLsz_TEXT);
void FCD_04071_LCD__PrintAscii(MX_UINT8 FCL_CHARACTER);
void FCD_04071_LCD__PrintNumber(MX_SINT16 FCL_NUMBER);
void FCD_04071_LCD__RAMWrite(MX_UINT8 FCL_INDEX, MX_UINT8 FCL_D0,
MX_UINT8 FCL_D1, MX_UINT8 FCL_D2, MX_UINT8 FCL_D3, MX_UINT8 FCL_D4,
MX_UINT8 FCL_D5, MX_UINT8 FCL_D6, MX_UINT8 FCL_D7);
void FCD_04071_LCD__ClearLine(MX_UINT8 FCL_LINE);
void FCD_04071_LCD__Cursor(MX_UINT8 FCL_X, MX_UINT8 FCL_Y);
void FCD_04071_LCD__Command(MX_UINT8 FCL_INSTRUCTION);
void FCD_04071_LCD__PrintFormattedNumber(MX_UINT32 FCL_NUMBER, MX_BOOL
FCL_FORMAT);
void FCD_04071_LCD__ScrollDisplay(MX_UINT8 FCL_POSITION, MX_UINT8
FCL_DIRECTION);
void FCD_04071_LCD__RawSend(MX_UINT8 FCL_DATA, MX_BOOL FCL_TYPE);
void FCD_04071_LCD__Start();
/*=====================================================================
===*\
Use :lcd_eb005
:???????? ??????????
:?????????? ???????? ????????????
\*=====================================================================
===*/
#define FCD_0ad31_lcd_eb005__Clear FCD_04071_LCD__Clear
#define FCD_0ad31_lcd_eb005__PrintString FCD_04071_LCD__PrintString
#define FCD_0ad31_lcd_eb005__PrintAscii FCD_04071_LCD__PrintAscii
#define FCD_0ad31_lcd_eb005__PrintNumber FCD_04071_LCD__PrintNumber
#define FCD_0ad31_lcd_eb005__RAMWrite FCD_04071_LCD__RAMWrite
#define FCD_0ad31_lcd_eb005__ClearLine FCD_04071_LCD__ClearLine
#define FCD_0ad31_lcd_eb005__Cursor FCD_04071_LCD__Cursor
#define FCD_0ad31_lcd_eb005__Command FCD_04071_LCD__Command
#define FCD_0ad31_lcd_eb005__PrintFormattedNumber
FCD_04071_LCD__PrintFormattedNumber
#define FCD_0ad31_lcd_eb005__ScrollDisplay FCD_04071_LCD__ScrollDisplay
#define FCD_0ad31_lcd_eb005__RawSend FCD_04071_LCD__RawSend
#define FCD_0ad31_lcd_eb005__Start FCD_04071_LCD__Start

/*=====================================================================
===*\
Use :????????????? ?? ?????? ??????????? ??? ????????????????
\*=====================================================================
===*/
#include "C:\Program Files (x86)\Flowcode 6\CAL\includes.c"
/*=====================================================================
===*\
Use :ButtonCtrl
:????????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :switch_base
:????????? ????????????
\*=====================================================================
===*/
/*=----------------------------------------------------------------------=*\
Use :Reads the button state as 0 for released or 1 for pressed
:Performs debounce if required
:
:?????????? : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCD_05261_switch_base__ReadState()
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_SWITCHVAL = (0xff); // Value of the press
MX_UINT16 FCL_DEL_COUNT;
MX_UINT8 FCL_OLD_SWITCHVAL;
MX_UINT8 FCR_RETVAL;
if (0 != FCP_GET(B, A, 0x1, 0x0))
{
FCR_RETVAL = 1;
} else {
FCR_RETVAL = 0;
}
#if (1) // 10 > 0
FCL_DEL_COUNT = 0;
FCL_OLD_SWITCHVAL = FCR_RETVAL;

while (FCL_DEL_COUNT < 10)


{
FCI_DELAYBYTE_MS(1);
if (0 != FCP_GET(B, A, 0x1, 0x0))
{
FCR_RETVAL = 1;
} else {
FCR_RETVAL = 0;
}
if (FCR_RETVAL == FCL_OLD_SWITCHVAL)
{
FCL_DEL_COUNT = FCL_DEL_COUNT + 1;
} else {
FCL_DEL_COUNT = 0;
}
FCL_OLD_SWITCHVAL = FCR_RETVAL;
}
// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#endif
return (FCR_RETVAL);
}
/*=----------------------------------------------------------------------=*\
Use :Waits until the switch is in state 'high'
:The interpretation of 'high' depends on the polarity
\*=----------------------------------------------------------------------=*/
void FCD_05261_switch_base__WaitUntilHigh()
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_SWITCHVAL = (0xff); // The state of the pin
MX_UINT16 FCL_DEL_COUNT;
MX_UINT8 FCL_OLD_SWITCHVAL;

while (1)
{
FCL_SWITCHVAL = FCP_GET(B, A, 0x1, 0x0);
#if (0) // 0 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
#if (1) // 10 > 0
FCL_DEL_COUNT = 0;
FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;
while (FCL_DEL_COUNT < 10)
{
FCI_DELAYBYTE_MS(1);
FCL_SWITCHVAL = FCP_GET(B, A, 0x1, 0x0);
#if (0) // 0 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
if (FCL_SWITCHVAL == FCL_OLD_SWITCHVAL)
{
FCL_DEL_COUNT = FCL_DEL_COUNT + 1;
} else {
FCL_DEL_COUNT = 0;
}
FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;
}
// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????

#endif
if ((FCL_SWITCHVAL == 0) == 0) break;
}
}
/*=----------------------------------------------------------------------=*\
Use :Waits until the switch is in state 'low'
:The interpretation of 'high' depends on the polarity
\*=----------------------------------------------------------------------=*/
void FCD_05261_switch_base__WaitUntilLow()
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_SWITCHVAL; // The state of the pin
MX_UINT16 FCL_DEL_COUNT;
MX_UINT8 FCL_OLD_SWITCHVAL;
while (1)
{
FCL_SWITCHVAL = FCP_GET(B, A, 0x1, 0x0);
#if (0) // 0 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
#if (1) // 10 > 0
FCL_DEL_COUNT = 0;
FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;
while (FCL_DEL_COUNT < 10)
{
FCI_DELAYBYTE_MS(1);
FCL_SWITCHVAL = FCP_GET(B, A, 0x1, 0x0);
#if (0) // 0 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
if (FCL_SWITCHVAL == FCL_OLD_SWITCHVAL)

{
FCL_DEL_COUNT = FCL_DEL_COUNT + 1;
} else {
FCL_DEL_COUNT = 0;
}
FCL_OLD_SWITCHVAL = FCL_SWITCHVAL;
}
// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#endif
if ((FCL_SWITCHVAL != 0) == 0) break;
}
}
/*=====================================================================
===*\
Use :ctrl_lcd
:????????? ????????????
\*=====================================================================
===*/
/*=====================================================================
===*\
Use :LCD
:????????? ????????????
\*=====================================================================
===*/
/*=----------------------------------------------------------------------=*\
Use :Clears the entire contents of the display.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Clear()
{

FCD_04071_LCD__RawSend(0x01, 0);
FCI_DELAYBYTE_MS(2);

FCD_04071_LCD__RawSend(0x02, 0);
FCI_DELAYBYTE_MS(2);
}
/*=----------------------------------------------------------------------=*\
Use :Breaks down a string of text and sends it to the LCD via the private RawSend(byte, mask)
macro
:
:?????????? ???????????? PrintString:
: Text[20] : Enter the text or variable to print to the LCD
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintString(MX_CHAR *FCL_TEXT, MX_UINT16 FCLsz_TEXT)
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_IDX = (0x0);
MX_UINT8 FCL_COUNT;

FCL_COUNT = FCI_GETLENGTH(FCL_TEXT, FCLsz_TEXT);


while (FCL_IDX < FCL_COUNT)
{
FCD_04071_LCD__RawSend(FCL_TEXT[FCL_IDX], 0x10);
FCL_IDX = FCL_IDX + 1;
}
}
/*=----------------------------------------------------------------------=*\
Use :Takes the ascii value for a character and prints the character
:
:?????????? ???????????? PrintAscii:
: character : Holds an ascii value.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintAscii(MX_UINT8 FCL_CHARACTER)
{
FCD_04071_LCD__RawSend(FCL_CHARACTER, 0x10);

/*=----------------------------------------------------------------------=*\
Use :Based on v5 macro, will allow you to print a number. This is limited to a signed-INT, -32768
to 32767
:
:?????????? ???????????? PrintNumber:
: Number : Enter the number or variable to print to the LCD
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintNumber(MX_SINT16 FCL_NUMBER)
{
//?????????? ?????????? ??????????
#define FCLsz_S 10
MX_CHAR FCL_S[FCLsz_S];
FCI_TOSTRING(FCL_NUMBER, FCL_S,10);
FCD_04071_LCD__PrintString(FCL_S, FCLsz_S);
//?????????? ?????????? ??????????
#undef FCLsz_S
}
/*=----------------------------------------------------------------------=*\
Use :Modifies the internal memory of the LCD to allow for up to 8 customised characters to be
created and stored in the device memory
:
:?????????? ???????????? RAMWrite:
: Index : Values 0 to 7
: d0 : MX_UINT8
: d1 : MX_UINT8
: d2 : MX_UINT8
: d3 : MX_UINT8
: d4 : MX_UINT8
: d5 : MX_UINT8
: d6 : MX_UINT8
: d7 : MX_UINT8
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__RAMWrite(MX_UINT8 FCL_INDEX, MX_UINT8 FCL_D0,
MX_UINT8 FCL_D1, MX_UINT8 FCL_D2, MX_UINT8 FCL_D3, MX_UINT8 FCL_D4,
MX_UINT8 FCL_D5, MX_UINT8 FCL_D6, MX_UINT8 FCL_D7)
{
FCD_04071_LCD__RawSend(64 + (FCL_INDEX << 3), 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(FCL_D0, 0x10);
FCD_04071_LCD__RawSend(FCL_D1, 0x10);
FCD_04071_LCD__RawSend(FCL_D2, 0x10);

FCD_04071_LCD__RawSend(FCL_D3, 0x10);
FCD_04071_LCD__RawSend(FCL_D4, 0x10);
FCD_04071_LCD__RawSend(FCL_D5, 0x10);
FCD_04071_LCD__RawSend(FCL_D6, 0x10);
FCD_04071_LCD__RawSend(FCL_D7, 0x10);
FCD_04071_LCD__Clear();
}
/*=----------------------------------------------------------------------=*\
Use :Clears a single line on the display and then moves the cursor to the start of the line to allow
you to start populating the line with data.
:
:?????????? ???????????? ClearLine:
: Line : The line to clear, zero being the first (top) line of the display
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__ClearLine(MX_UINT8 FCL_LINE)
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_X;
if (FCL_LINE < 2)
{
FCD_04071_LCD__Cursor(0, FCL_LINE);
FCL_X = 0;
while (FCL_X < 16)
{
FCD_04071_LCD__RawSend(' ', 0x10);
FCL_X = FCL_X + 1;
}
FCD_04071_LCD__Cursor(0, FCL_LINE);
// } else {
}
}

/*=----------------------------------------------------------------------=*\
Use :Moves the cursor on the LCD Display
:
:?????????? ???????????? Cursor:
: x : Set the cursor position in the X plane, 0 is the left most cell
: y : Set the cursor position in the Y plane, 0 is the top most cell
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Cursor(MX_UINT8 FCL_X, MX_UINT8 FCL_Y)
{

#if (0) // 2 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
#if (1) // 2 == 2
if (FCL_Y == 0)
{
FCL_Y = 0x80;
} else {
FCL_Y = 0xC0;
}
// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#endif
#if (0) // 2 == 4
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
FCD_04071_LCD__RawSend(FCL_Y + FCL_X, 0);
FCI_DELAYBYTE_MS(2);
}
/*=----------------------------------------------------------------------=*\

Use :Use this method/macro to send a specific command to the LCD. Refer to the Matrix
Multimedia EB006 datasheet for a list of supported instructions. For Non-Matrix LCD's refer to the
manufacturers datasheet.
:
:?????????? ???????????? Command:
: instruction : Send a defined command to the LCD Screen. See datasheet for supported
commands.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Command(MX_UINT8 FCL_INSTRUCTION)
{
FCD_04071_LCD__RawSend(FCL_INSTRUCTION, 0);
FCI_DELAYBYTE_MS(2);
}
/*=----------------------------------------------------------------------=*\
Use :Will allow you to print a number up to 32-bits with signed or unsigned formatting.
:Signed = -2147483648 to 2147483647
:Unsigned = 0 to 4294967295
:
:?????????? ???????????? PrintFormattedNumber:
: Number : Enter the number or variable to print to the LCD
: Format : 0=Signed, 1=Unsigned
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__PrintFormattedNumber(MX_UINT32 FCL_NUMBER, MX_BOOL
FCL_FORMAT)
{
//?????????? ?????????? ??????????
#define FCLsz_S 15
MX_CHAR FCL_S[FCLsz_S];
if (FCL_FORMAT == 1)
{
FCI_UTOS32(FCL_NUMBER, FCL_S,15);
} else {
FCI_ITOS32((MX_SINT32)(FCL_NUMBER), FCL_S,15);
}
FCD_04071_LCD__PrintString(FCL_S, FCLsz_S);
//?????????? ?????????? ??????????
#undef FCLsz_S
}
/*=----------------------------------------------------------------------=*\

Use :Scrolls the display left or right by a number of given positions.


:
:?????????? ???????????? ScrollDisplay:
: Position : Holds the number of positions to shift the display
: direction : 0 = left, 1 = right
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__ScrollDisplay(MX_UINT8 FCL_POSITION, MX_UINT8
FCL_DIRECTION)
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_CMD = (0x0);
FCL_CMD = 0;
switch (FCL_DIRECTION)
{
case 0:
{
FCL_CMD = 0x18;
break;
}
case 'l':
{
FCL_CMD = 0x18;
break;
}
case 'L':
{
FCL_CMD = 0x18;
break;
}
case 1:
{
FCL_CMD = 0x1C;
break;
}
case 'r':
{
FCL_CMD = 0x1C;
break;
}

case 'R':
{
FCL_CMD = 0x1C;
break;
}
// default:
}
if (FCL_CMD != 0 && FCL_POSITION != 0)
{
while (FCL_POSITION != 0)
{
FCD_04071_LCD__RawSend(FCL_CMD, 0);
FCL_POSITION = FCL_POSITION - 1;
}
// } else {
}
}
/*=----------------------------------------------------------------------=*\
Use :Sends data to the LCD display
:
:?????????? ???????????? RawSend:
: data : The data byte to send to the LCD
: type : A boolean to indicate command type: true to write data, false to write a command
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__RawSend(MX_UINT8 FCL_DATA, MX_BOOL FCL_TYPE)
{
//?????????? ?????????? ??????????
MX_UINT8 FCL_NIBBLE;
//??????:
//Output upper nibble of the byte
#if (1) // 0 == 0
FCP_SET(B, B, 0x1, 0x0, 0);
FCP_SET(B, B, 0x2, 0x1, 0);
FCP_SET(B, B, 0x4, 0x2, 0);
FCP_SET(B, B, 0x8, 0x3, 0);

FCP_SET(B, B, 0x10, 0x4, 0);


FCP_SET(B, B, 0x20, 0x5, 0);
#if (0)
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
FCL_NIBBLE = (FCL_DATA >> 4);
FCP_SET(B, B, 0x1, 0x0, (FCL_NIBBLE & 0x01));
FCL_NIBBLE = FCL_NIBBLE >> 1;
FCP_SET(B, B, 0x2, 0x1, (FCL_NIBBLE & 0x01));
FCL_NIBBLE = FCL_NIBBLE >> 1;
FCP_SET(B, B, 0x4, 0x2, (FCL_NIBBLE & 0x01));
FCL_NIBBLE = FCL_NIBBLE >> 1;
FCP_SET(B, B, 0x8, 0x3, (FCL_NIBBLE & 0x01));
// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#endif
//??????:
//Output byte to pins
#if (0) // 0 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
//??????:
//Output byte to port
#if (0) // 0 == 2
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
if (FCL_TYPE)
{
FCP_SET(B, B, 0x10, 0x4, 1);
// } else {
}

FCI_DELAYBYTE_US(100);
//??????:
//Set Enable high, pause then set low
//to acknowledge the data has been
//submitted.
FCP_SET(B, B, 0x20, 0x5, 1);
FCI_DELAYBYTE_US(100);
FCP_SET(B, B, 0x20, 0x5, 0);
FCI_DELAYBYTE_US(100);
#if (1) // 0 == 0
FCP_SET(B, B, 0x1, 0x0, 0);
FCP_SET(B, B, 0x2, 0x1, 0);
FCP_SET(B, B, 0x4, 0x2, 0);
FCP_SET(B, B, 0x8, 0x3, 0);
FCP_SET(B, B, 0x10, 0x4, 0);
FCL_NIBBLE = (FCL_DATA & 0xf);
FCP_SET(B, B, 0x1, 0x0, (FCL_NIBBLE & 0x01));
FCL_NIBBLE = FCL_NIBBLE >> 1;
FCP_SET(B, B, 0x2, 0x1, (FCL_NIBBLE & 0x01));
FCL_NIBBLE = FCL_NIBBLE >> 1;
FCP_SET(B, B, 0x4, 0x2, (FCL_NIBBLE & 0x01));
FCL_NIBBLE = FCL_NIBBLE >> 1;
FCP_SET(B, B, 0x8, 0x3, (FCL_NIBBLE & 0x01));
if (FCL_TYPE)
{
FCP_SET(B, B, 0x10, 0x4, 1);
// } else {
}
FCI_DELAYBYTE_US(100);
FCP_SET(B, B, 0x20, 0x5, 1);
FCI_DELAYBYTE_US(100);
FCP_SET(B, B, 0x20, 0x5, 0);
FCI_DELAYBYTE_US(100);

// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#endif
}
/*=----------------------------------------------------------------------=*\
Use :Startup routine required by the hardware device.
:Automatically clears the display after initialising.
\*=----------------------------------------------------------------------=*/
void FCD_04071_LCD__Start()
{

#if (1) // 0 == 0
FCP_SET(B, B, 0x1, 0x0, 0);
FCP_SET(B, B, 0x2, 0x1, 0);
FCP_SET(B, B, 0x4, 0x2, 0);
FCP_SET(B, B, 0x8, 0x3, 0);
FCP_SET(B, B, 0x10, 0x4, 0);
FCP_SET(B, B, 0x20, 0x5, 0);
// #else
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#endif
#if (0) // 0 == 1
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
#if (0) // 0 == 2
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
#if (0)
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
// #else
#endif
FCI_DELAYBYTE_MS(12);

FCD_04071_LCD__RawSend(0x33, 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(0x33, 0);
FCI_DELAYBYTE_MS(2);
#if (0) // 0 > 0
//? ??????? ???? ??????????????? ??? ??? ??? - ???????????
#else
FCD_04071_LCD__RawSend(0x32, 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(0x2c, 0);
#endif
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(0x06, 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(0x0c, 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(0x01, 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__RawSend(0x02, 0);
FCI_DELAYBYTE_MS(2);
FCD_04071_LCD__Clear();
}
/*=====================================================================
===*\
Use :lcd_eb005
:????????? ????????????
\*=====================================================================
===*/

/*=====================================================================
===*\
Use :panel
:????????? ????????????
\*=====================================================================
===*/
/*=----------------------------------------------------------------------=*\
Use :
\*=----------------------------------------------------------------------=*/
void FCM_TMR_INT()
{
// Increment Interrupt Count
// ???????????:
// count = count + 1
FCV_COUNT = FCV_COUNT + 1;
// 75 Interrupts in 1 Sec @ 19.6608MHz
// ????????: count < 75?
if (FCV_COUNT < 75)
{
} else {
// Set flag to allow LCD to update
// ???????????:
// update_display = 1
FCV_UPDATE_DISPLAY = 1;
// Store count variable into Display copy
// ???????????:
// Display_Freq = freq
FCV_DISPLAY_FREQ = FCV_FREQ;
}
}
/*=----------------------------------------------------------------------=*\
Use :
\*=----------------------------------------------------------------------=*/
void FCM_Read_input()
{
// Read Input Pin
// ???????: A0 -> in
FCV_IN = FCP_GET(B, A, 0x01, 0);
}

/*=====================================================================

===*\
Use :????????
\*=====================================================================
===*/
int main()
{
MCUCR=0x00;
MCUSR=0x00;
wdt_disable();
EIMSK=0x00;
//??????:
//Prints out the freqency of
//pulses incoming to the pin
//specified in macro Read_Input
//Max Input freq approx 32000Hz
//This can be simulated by pressing the SMT switch in the system panel
//during simulation
// Init LCD
// ????? ???????????? ???????????: lcd_eb005::Start()
FCD_0ad31_lcd_eb005__Start();
// Init Counters
// ???????????:
// freq = 0
// count = 0
// update_display = 0
FCV_FREQ = 0;
FCV_COUNT = 0;
FCV_UPDATE_DISPLAY = 0;
// Init In Variable
// ????? Macro: Read_input()
FCM_Read_input();
// Start Interrupt
// ???????: ???????????? TMR0
TCCR0B &= 0xf8;
TCCR0B |= 0x01;
sei();
TIMSK0 |= (1 << TOIE0);
// Main Loop
// ??????: While 1
while (1)
{
// Is the count ready to display?
// ????????: update_display?

if (FCV_UPDATE_DISPLAY)
{
// Init Cursor
// ????? ???????????? ???????????: lcd_eb005::Cursor(0, 0)
FCD_0ad31_lcd_eb005__Cursor(0, 0);
// Output Label
// ????? ???????????? ???????????: lcd_eb005::PrintString("Freq = ")
FCD_0ad31_lcd_eb005__PrintString("Freq = ", 8);
// Output Frequency
// ????? ???????????? ???????????: lcd_eb005::PrintNumber(Display_Freq)
FCD_0ad31_lcd_eb005__PrintNumber(FCV_DISPLAY_FREQ);
// Output Units
// ????? ???????????? ???????????: lcd_eb005::PrintString(" Hz ")
FCD_0ad31_lcd_eb005__PrintString(" Hz ", 7);
// Reset Counters
// ???????????:
// freq = 0
// count = 0
// update_display = 0
FCV_FREQ = 0;
FCV_COUNT = 0;
FCV_UPDATE_DISPLAY = 0;
// Reset Timer Count register to 0
// ??????? C:
tmr0 = 0x00;
} else {
// Wait Until Low Or Update flag set
// ??????: While in = 1 && update_display = 0
while (FCV_IN == 1 && FCV_UPDATE_DISPLAY == 0)
{
// Collect Input
// ????? Macro: Read_input()
FCM_Read_input();
}
// Wait Until High Or Update flag set
// ??????: While in = 0 && update_display = 0
while (FCV_IN == 0 && FCV_UPDATE_DISPLAY == 0)
{

// Collect Input
// ????? Macro: Read_input()
FCM_Read_input();
}
// Increment Count
// ???????????:
// freq = freq + 1
FCV_FREQ = FCV_FREQ + 1;
}
}
mainendloop: goto mainendloop;
}

/*=====================================================================
===*\
Use :???????
\*=====================================================================
===*/
//Handler code for [TMR0]
#ifndef MX_TIMER0OVF_HANDLER
#define MX_TIMER0OVF_HANDLER
ISR(TIMER0_OVF_vect)
{
FCM_TMR_INT();
}
#else
#warning The <TIMER0 OVF> interrupt has previously been enabled, so the macro
<TMR_INT> may never get called.
#endif

Das könnte Ihnen auch gefallen