FreescaleCMT
 
Component FreescaleCMT
Freescale Carrier Modulator Timer
Component Level: Low
Typical Usage:
(Examples of a typical usage of the component in user code. For more information please see the page Component Code Typical Usage.)


Typical settings and usage of FreescaleCMT bean


(1) Sending data using pulse width modulation

Assume the component name "CM1". Properties setting:

Interrupt service/event: Enabled, Mode: Baseband (Time is also possible), Modulation space: Enabled, Mark pulse width: 10 ms, Space pulse width: two modes are defined in timing dialog using Runtime settings type 'from list of values', 10 ms and 20 ms. Methods enabled: Enable, Disable, SetSpaceWidthMode

The typical usage of this component shows sending a byte of data by means of PWM modulation. Logic 1 is send by 10 ms mark and 20 ms space. Logic 0 is send by 10 ms mark and 10 ms space.

MAIN.C

volatile byte OnEnd;                 /* The OnEnd event flag */

void SendBytePWM(byte Data)          /* Sends a byte by PWM modulated signal */
{
  byte i;

  OnEnd=0;
  if(Data & 0x01) {
    (void)CM1_SetSpaceWidthMode(1);  /* LSB=1 */
  }
  else {
    (void)CM1_SetSpaceWidthMode(0);  /* LSB=0 */
  }
  (void)CM1_Enable();                /* Enable the signal output */
  for(i=7;i!=0;i--){                 /* Send the rest of the byte - 7 bits */
    Data = Data >> 1;                /* Right shift the data */
    while(!OnEnd) ;                  /* Wait for end of modulation cycle */
    OnEnd = 0;                       /* Clear the event flag */
    if(Data & 0x01) {
      (void)CM1_SetSpaceWidthMode(1);  /* bit=1 */
    }
    else {
      (void)CM1_SetSpaceWidthMode(0);  /* bit=0 */
    }
  }
  while(!OnEnd) ;                     /* Wait for end of modulation cycle */
  (void)CM1_Disable();                /* Disable the signal output */
}

void main(void)
{
.
.
  SendBytePWM(0xa9);                  /* Send 0xa9 as a data */
.
.
}

EVENTS.C

extern volatile byte OnEnd;

void CM1_OnEnd(void)
{
  OnEnd++;
}

(2) Sending data using FSK modulation

Assume the component name "CM1". Properties setting:

Interrupt Service/event: Enabled, Mode: FSK, Primary carrier frequency settings: F1 = 2 kHz, primary carrier high pulse width and low pulse width = 250 us, Secondary carrier frequency settings: F2 = 4 kHz, secondary carrier high pulse width and low pulse width = 125 us, Mark pulse width in carrier clocks: 5, Modulation space: Disabled, Methods enabled: Enable, Disable, SwapCarrierFreq.

The typical usage of this component shows sending a byte of data by means of FSK modulation. Each bit is modulated by two carrier frequencies. Logic 0 by F1 followed with F2 and logic 1 by F2 followed with F1.


MAIN.C

volatile byte OnEnd;               /* The OnEnd event flag */

void SendByteFSK(byte Data)        /* Sends a byte by FSK modulated signal */
{
  byte i;
  byte Last;

  Last = 0;
  if(Data & 0x01) {
    (void)CM1_SwapCarrierFreq();     /* LSB=1 */
    Last ^= 1;                       /* store last transmitted byte*/
  }
  (void)CM1_Enable();                /* Enable the signal output */
  OnEnd = 0;
  for(i=7;i!=0;i--){                 /* Send the rest of the byte - 7 bits */
    Data = Data >> 1;                /* Right shift the data */
    while(OnEnd != 2) ;               /* Wait for two modulation cycles */
    OnEnd = 0;                       /* Clear the event flag */
    if((Data & 0x01)!=Last) {
      (void)CM1_SwapCarrierFreq();   /* Bit is different from last one sent */
      Last ^= 1;                     /* Store last transmitted byte*/
    }
  }
  while(OnEnd != 1) ;                 /* Wait for one modulation cycle */
  (void)CM1_Disable();               /* Disable the signal output */
}

void main(void)
{
.
.
  SendByteFSK(0xa9);                 /* Send 0xa9 as a data */
.
.
}

EVENTS.C

extern volatile byte OnEnd;

void CM1_OnEnd(void)
{
  OnEnd++;
}