Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

FMD MCU

hassana

Newbie level 6
Joined
Jan 16, 2005
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
90
is there anyone has experience with FMD MCU?
 
I want to use FT60E211 to measure high pulse width range 150us to 25ms
is there an example?
 
Hi,

Not sure whether your microcontroller supports CAPTURE feature. Just found a Chinese datasheet.

Most accurate approach:
* set up a 16bit timer/counter to count with 1MHz
* use CAPTURE method on both edges
* calculate CAPTURE_Falling - CAPTURE_Rising

Klaus
 
Hi,

Not sure whether your microcontroller supports CAPTURE feature. Just found a Chinese datasheet.

Most accurate approach:
* set up a 16bit timer/counter to count with 1MHz
* use CAPTURE method on both edges
* calculate CAPTURE_Falling - CAPTURE_Rising

Klaus
I will use FT60E211_RB it has 16bit timer2

can you help me?
 
Hi,

questions like:
* "is there anyone has experience with FMD MCU?"
* "can you help me?"
are useless. They just make the thread longer and longer.

--> just provide all informations about your situation
--> then ask detailed, elaborated questions.

Informations we need:
* a link to an English datasheet
* your IDE, language, compiler
* your SW approach. At least a flow chart ... or a clear description. A sketch often is better than a lot of words.
* what is clear so far?

Question:
* what exactly is the problem?

****
We don´t know whether you never had a resistor in your hand ... whether you are experiened in programming, ...whether you have difficulties in understanding
datasheets.

We can´t replace school. We won´t do the whole engineering job for you.
But we can help you rectify some detailed problems.

Klaus
 
You need a sync to start/stop 12 bit time interval counter on positive duration, with other 8 bit timer for any other purpose such as a digital FLL or as a prescaler for 20 bit counter.

If you do not have a design spec, you cannot design.
 
Hi,

questions like:
* "is there anyone has experience with FMD MCU?"
* "can you help me?"
are useless. They just make the thread longer and longer.

--> just provide all informations about your situation
--> then ask detailed, elaborated questions.

Informations we need:
* a link to an English datasheet
* your IDE, language, compiler
* your SW approach. At least a flow chart ... or a clear description. A sketch often is better than a lot of words.
* what is clear so far?

Question:
* what exactly is the problem?

****
We don´t know whether you never had a resistor in your hand ... whether you are experiened in programming, ...whether you have difficulties in understanding
datasheets.

We can´t replace school. We won´t do the whole engineering job for you.
But we can help you rectify some detailed problems.

Klaus
I want to use FMD MCU (FT60E211) to measure pulse width that generated from HC-SR04 ultrasonic sensor so looking for a simple code to start
 
If you are using C find an example project and adapt code to the specific
MCU you select.....or at least see basic overview of what was done.

You would map registers and their addresses to your specific part, and
look at operational aspect of your HW versus target the code came from.

Or just tackle it from scratch a piece, a function at a time.

Does support from manufacturer have examples in their IDE for basic work,
like PWM setup and run.....?

Regards, Dana.
 
MCU is FT60F211
then it has timer2 as 16bit
compiler is FMD IDE
I want to measure just high pulse width using timer2 as counter can you help me in code?

this is example code but not understood

Code:
//*********************************************************
/*  ÎļþÃû£ºTest_60F21X_Timer2.c
*    ¹¦ÄÜ£º  FT60F21X_Timer2¹¦ÄÜÑÝʾ
*   IC:    FT60F21X SOP8
*   ¾§Õñ£º  16M/4T                  
*   ˵Ã÷£º  µ±DemoPortInÐü¿Õ»òÕ߸ߵçƽʱ,
*           DemoPortOutÊä³ö2.5KHzÕ¼¿Õ±È50%µÄ²¨ÐÎ-Tm2ʵÏÖ
*           µ±DemoPortIn½ÓµØʱ,DemoPortOutÊä³ö¸ßµçƽ.¹Ø¶¨Ê±Æ÷
*/
//===========================================================
//===========================================================
#include    "SYSCFG.h";
#include     "FT60F21X.h";

#define  unchar     unsigned char
#define  unint      unsigned int
#define  unlong     unsigned long

//===========================================================
//
//    ϵͳʱÖÓ
//===========================================================
#define OSC_16M  0X70
#define OSC_8M   0X60
#define OSC_4M   0X50
#define OSC_2M   0X40
#define OSC_1M   0X30
#define OSC_500K 0X20
#define OSC_250K 0X10
#define OSC_32K  0X00

#define  DemoPortOut    RA4
#define  DemoPortIn        RA2
//===========================================================
//±äÁ¿¶¨Òå
//===========================================================

//===========================================================
//Funtion name£ºinterrupt ISR
//parameters£ºÎÞ
//returned value£ºÎÞ
//===========================================================
void interrupt ISR(void)
{
  //¶¨Ê±Æ÷2µÄÖжϴ¦Àí**********************
    if(TMR2IE && TMR2IF)            //200usÖжÏÒ»´Î = 2.5KHz
    {
        DemoPortOut = ~DemoPortOut; //·×ªµçƽ
        TMR2IF = 0;
    }
}

/*-------------------------------------------------
 * º¯ÊýÃû£ºPOWER_INITIAL
 *    ¹¦ÄÜ£º  Éϵçϵͳ³õʼ»¯
 * ÊäÈ룺  ÎÞ
 * Êä³ö£º  ÎÞ
 --------------------------------------------------*/  
void POWER_INITIAL (void)
{
    OSCCON = OSC_16M;    //    bit7    Timer2 Ñ¡ÔñLIRCΪʱÖÓԴʱ LIRCµÄƵÂÊÑ¡Ôñ  0:32KHz    1:256KHz
                                        //bit[6:4]    ϵͳƵÂÊÑ¡Ôñ  
                                        //bit[2]        ¸ßËÙÄÚ²¿Ê±ÖÓ״̬    1:ready    0:not ready
                                        //bit[1]        µÍËÙÄÚ²¿Ê±ÖÓ״̬    1:ready    0:not ready

    INTCON = 0;                  //ÔݽûÖ¹ËùÓÐÖжÏ
    OPTION = 0;
    TRISA    = 1<<2;            //1:ÊäÈë    0:Êä³ö      
    PSRCA     = 0;                    //00:    4mA        01/10:    8mA        11:    28mA    bit[3:2]¿ØÖÆPA5Ô´µçÁ÷    bit[1:0]¿ØÖÆPA4Ô´µçÁ÷
    PSINKA    = 0;                    //bit[1:0]    ¿ØÖÆPA5ºÍPA4        0:¹àµçÁ÷×îС    1:¹àµçÁ÷×î´ó
    PORTA     = 0;                    //1:PAxÊä³ö¸ßµçƽ    0:PAxÊä³öµÍµçƽ
     WPUA     = 1<<2;            //1:    ʹÄÜPA¿ÚÉÏÀ    0:¹Ø±ÕPA¿ÚÉÏÀ  
}
/*-------------------------------------------------
 * º¯ÊýÃû³Æ£º  TIMER2_INITIAL
 * ¹¦ÄÜ£º     ³õʼ»¯ÉèÖö¨Ê±Æ÷1
 * Ïà¹Ø¼Ä´æÆ÷£ºT2CON TMR2 PR2 TMR2IE TMR2IF PEIE GIE
 -------------------------------------------------*/
void TIMER2_INITIAL (void)
{
    T2CON0 = 0B00000001;     //Bit[1,0]=01,T2ʱÖÓ·ÖƵ 1:4
                                            //Bit[6-3]=0000,T2Êä³öʱÖÓ·ÖƵ1:1
    T2CON1 = 0B00001000;    //Bit[2:0] 000:    Ö¸ÁîÖÜÆÚ    100:HIRC        Timer2ʱÖÓÔ´Ñ¡Ôñ  
    TMR2H = 0;
    TMR2L = 0;                      //TMR2¸³³õÖµ
    PR2H =0;
    PR2L = 200;                     //ÉèÖÃTMR2Êä³ö±È½ÏÖµ¶¨Ê±200us=(1/16000000)*4*4*200(PR2)
                                            //16M-4T-4·ÖƵ
    TMR2IF = 0;                        //ÇåTIMER2ÖжϱêÖ¾
    TMR2IE = 1;                        //ʹÄÜTIMER2µÄÖжÏ
    TMR2ON = 1;                    //ʹÄÜTIMER2Æô¶¯
    PEIE=1;                            //ʹÄÜÍâÉèÖжÏ
    GIE = 1;                           //ʹÄÜÈ«¾ÖÖжÏ
}
/*-------------------------------------------------
 * º¯ÊýÃû: main
 *    ¹¦ÄÜ£º  Ö÷º¯Êý
 * ÊäÈ룺  ÎÞ
 * Êä³ö£º  ÎÞ
 --------------------------------------------------*/
void main()
{
    POWER_INITIAL();            //ϵͳ³õʼ»¯
   
    TIMER2_INITIAL();              //³õʼ»¯T2
   
    while(1)
    {
        if(DemoPortIn == 1)    //ÅжÏÊäÈëÊÇ·ñΪ¸ßµçƽ
        {
            TMR2IE = 1;             //¿ª¶¨Ê±Æ÷2
        }
        else
        {
            TMR2IE = 0;             //¹Ø¶¨Ê±Æ÷2
            DemoPortOut = 1;
        }
    }
}
//===========================================================
 
Last edited:
Any chance you can paste code into word and use google translate to
change comments to english ?

If you are trying to measure PW basically enable a counter to run with
transition from low to high on input pin, it then counts while pin is high,
then when pin goes low counter stops, the - edge of pin triggers an interrupt,
interrupt reads counter value, and resets counter.

The period is counts x counter clock period. So if clock was 1 us, and counter
read was 10, then PW = 10 uS.

You typically pick a clock so that at smallest PW you want to measure in the
counter will take ~ 5 clocks minimum. The more the better, because that
makes more accurate the reading. But you tradeoff counter size because
as you seek finer resolution, higher clock freq, counter must get bigger to
read the widest PW in you want to measure.

Now lastly you have to take care of counter overflow for an out of range input.
So another isr for a carry out triggered interrupt will tell you its overflowed and
you have to add to final PW counter read the max count value of the counter
to get accurate reading.

In your ISRs best practice is to set a flag and return to main code to process. You
want in general to not call f()'s in ISR because that creates a lot of stack push saving
variables before the f() is called. It also wastes CPU time. Also declare variables used
in ISR as VOLATILE, google this for explanation why thats needed. Also google good
ISR coding practices......


Regards, Dana.
--- Updated ---

I want to use FT60E211 to measure high pulse width range 150us to 25ms
is there an example?

What accuracy do you want to do this to ? What size are the counters in this part ?
Do you have a datasheet link for this part, that you can post here, hopefully in English
or use a utility on web to translate it.

Regards, Dana.
 
Last edited:

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top