جدیترین مقالات

FT61F02x IO Application

IO related register settings

PORTA/PORTC is an 8-bit bidirectional port. The corresponding in and out direction register is the TRISA/TRISC register. (But note that bit 5 is not used here because PORTA[5] is a single input direction port. Setting a bit to “1” in the TRISA/TRISC register will set the corresponding PORTA/PORTC port as an input port (At this time, the output driver circuit will be turned off. On the contrary, setting a bit to “0” will set the corresponding PORTA/PORTC port as an output port. When set as an output port, the output driver circuit will be turned on , the data in the output register will be placed in the output port. When a read operation is performed on PORTA/PORTC, the content of PORTA/PORTC will reflect the state of the input port. When a write operation is performed on PORTA/PORTC, the content of PORTA/PORTC will be Is written to the output register. All write operations are a micro-flow of “read-change-write”, that is, the process of data being read, then changed, and then written to the output register. When MCLRE is 1, PORTA[5] reads The value is 0, at this time it is used as an external reset pin.

The respective bits of the relevant registers are defined as follows

FMD001
PORTA Register

Bit7
PORTA7 data
Bit6
PORTA6 data
Bit5
(PORTA5 (only has input function, there is no corresponding data register
Bit4
PORTA4 data
Bit3
PORTA3 data
Bit2
PORTA2 data
Bit1
PORTA1 data
Bit0
PORTA0 data

FMD002
PORTC Register

Bit7~Bit0
PORTC data register

FMD003
TRISA Register

Bit7~ Bit6
PORTA<7:6> Input Output Status Control Register
1: The port is in input state

0: The port is in output state

Bit 5
Input port only, read as 0

Bit4~Bit0 Bit0: PORTA<4:0> Input Output Status Control Register
1: The port is in input state
0: The port is in output state

FMD004
TRISC Register

Bit7~ Bit0
PORTC<7:0> Input Output Status Control Register
1: The port is in input state
0: The port is in output state

FMD005
WPUA Register

Bit7~Bit6
Bit4~Bit0 PORTA weak pull-up enable
1: Enable PORTA port weak pull-up
0: Disconnect weak pull-up of PORTA port

Bit5
The weak pull-up function of PORTA[5] is determined by the configuration register bit MCRLE
MCLRE=1
: Enable weak pull-up of PA5
MCLRE=0
: Disable weak pull-up of PA5

FMD006
WPUC Register

Bit5~Bit0
PORTC weak pull-up enable
1: Enable PORTC port weak pull-up
0: Disconnect the weak pull-up of the PORTC port

FMD007
OPTION Register

Bit
7 PORTA port pull-up enable bit
1: The pull-up function is disabled
0: Pull-up function enabled
Bit6: Trigger interrupt edge selection bit
1-> PC1/INT rising edge triggers interrupt
0-> PC1/INT falling edge trigger interrupt
Bit5
Timer0 clock select bits
1: PA2/T0CKI pin input clock
0: Internal instruction cycle Fosc/2
Bit4: Timer0 clock edge select bit
1: The count increases when the PA2/T0CKI pin changes from high to bottom
0: The count increases when the PA2/T0CKI pin changes from low to high
Bit3: Prescaler allocation bit
1: Prescaler assigned to WDT
0: Prescaler assigned to Timer0
Bit2~Bit0 Prescaler size setting bits

FMD008 1 1

Application example

*
*/
//************************************
#include "SYSCFG.h"
//************************macro definition*********
//************************

#define unchar unsigned char
#define unint
  unsigned int
#define unlong
 unsigned long
#define DemoPortOut
 RA3 //
#define DemoPortIn
  RC3
 //

//Function name: POWER_INITIAL
//Function: Power-on system initialization
//* input: none
//* output: none
void POWER_INITIAL
(void)
{
    OSCCON = 0B01110001; //WDT 32KHZ IRCF=111=16MHZ/2=8MHZ,0.125US/T
    //Bit0= system clock is internal oscillator
    //Bit0= The clock source is determined by FOSC<2 0>, i.e. selected when compiling options
    INTCON = 0; temporarily disable all interrupts
    PORTA = 0B00000000;
    TRISA = 0B11110111; //PA input output 0 output 1 input
    //PA3 output
    PORTC = 0B00000000;
    TRISC = 0B11111111; //PC input output 0 output 1 input
    WPUA = 0B00000000; //PA port pull-up control 1 open pull-up 0 close pull-up
    WPUC = 0B00001000; //PC port pull-up control 1 open pull-up 0 close pull-up
    OPTION = 0B00001000; //Bit 3 =1 WDT MODE,PS=000=1:1 WDT RATE
    // P APU)=0 ENA BLED PULL UP PA
    MSCKCON = 0B00000000; B it6 --> disable PA4 PC5 regulated output
    B it5 --> 0, TIMER2 clock is Fosc
    B it4 --> disable LVR
    CMCON0 = 0B00000111; close the comparator, CxIN is the digital IO port
}

//Fremont Micro Devices FT61F02X Application Note
//© 2017 Fremont Micro Devices Inc. page7
//** Function Name: Function Name: DelayUsDelayUs
//** Function: Function: The number of short delay functions and short delay functions ----16M16M--2T2T--//-about 1% faster about 1% faster..
//** Input parameters: Input parameters: TimeTime delay time length delay time length delay time length //delay time length TimeTime UsUs
//** Return parameter: None Return parameter: None
//-------------------------------------------------- ------------------------------------------------*/ */

void DelayUs(unsigned char Time)
{
    unsigned char a;unsigned char a;
    for(a=0;a<Time;a++)for(a=0;a<Time;a++)
    {
        {
        NOP();NOP();
        }
    }
}
//
//------------------------------------------------ --------------------------------------------------
// Function Name: Function Name: DelayMsDelayMs
// Function: Function: Short Delay Function Short Delay Function
// Input parameters: Input parameters: TimeTime delay time length delay time length delay time length //delay time length TimeTime msms
// Return parameter: None Return parameter: None
//-------------------------------------------------- ------------------------------------------------*/ */
void DelayMs(unsigned char Time)
{
unsigned char a,b;
for(a=0;a<Time;a++)
for(b=0;b<5;b++)
D elayUs(197); 快 1%
}
/*------------------------------------------------ --------------------------------------------------
** Function Name: Function Name: DelaySDelayS
** Function: Function: Short Delay Function Short Delay Function
** Input parameters: Input parameters: TimeTime delay time length delay time length delay time length delay time length TimeTime SS
** Return parameter: None Return parameter: None
-------------------------------------------------- ------------------------------------------------*/ */
void DelayS(unsigned char Time)
void DelayS(unsigned char Time)
{
{
unsigned char unsigned char a,b;a,b;
for(a=0;a<Time;a++)for(a=0;a<Time;a++)
{{
for(b=0;b<10;b++)for(b=0;b<10;b++)
{{
Fremont Micro Devices FT61F02X Application Note
© 2017 Fremont Micro Devices Inc. page8
DelayMs(100); DelayMs(100);
}}
}}
}
}
/*
/*------------------------------------------------ --------------------------------------------------
* * function name function name: main : main
** function: function: main function main function
* * input: input: none none
* * output: output: none none
-------------------------------------------------- -------------------------------------------------- */*/
void main()
void main()
{
{
POWPOWER_INITIAL();ER_INITIAL(); ////System initialization System initialization
while(1)while(1)
{{
DemoPortOut = 1; DemoPortOut = 1;
DelayMs(10); DelayMs(10); //10ms//10ms
if(DemoPortIn == 1) if(DemoPortIn == 1) ////Determine whether the input is high to determine whether the input is high
{{
DemoPortOut = 0;DemoPortOut = 0;
}}
DelayMs(10); DelayMs(10);
}}
}
}
WhatsApp
Email
LinkedIn

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *