This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320f20827 driving the dds ad9851 chip

Hi guys,

I am new to the tms320f027. 

I would like to drive the direct digital synthesizer (dds) ad9851 chip in order to produce the sine (i acknowledge that there are different ways without using the dds chip; however, i need to use it)

Could you help me, please, with it?

Thanks.

  • Hi,

    I would like to drive the direct digital synthesizer (dds) ad9851 chip

    Can you brief on the application or atleast some kind of block diagram? In short, what do you want to do with F28027, role of F29027?

    Regards,

    Gautam

  • Hi Gautam,

    It's just DDS AD9851 connected to the F28027. So, F28027 will invoke the DDS AD9851 chip that produces accurate sin wave.

    Specifically, I need these pins:

                 1) Word Load Clock. Rising edge loads the parallel or serial frequency/phase/control words asynchronously into the 40-bit input register.

                 2) Frequency Update. A rising edge asynchronously transfers the contents of the 40-bit input register to be acted upon by the DDS core. FQ_UD should be issued when the contents of the input register are known to contain only valid, allowable data

                 3) 8-Bit Data Input. The data port for loading the 32-bit frequency and 8-bit phase/control words. 

                 4) Master Reset pin; active high; clears DDS accumulator and phase offset register to achieve 0 Hz and 0° output phase. Sets programming to parallel mode and disengages the 6 REFCLK Multiplier. Reset does not clear the 40-bit input r.

     

    I started from the example "f2802x timed_blink" from the Control_suite. However, I could not figure out these pins.

    Definitely, I have read the datasheet 'million' times. It's hard for me to start from the scratch. I think it's a piece of cake for the ppl who have played with the microcontroller a lot.

  • Aidyn,

    I think you may also want to look at the GPIO setup and GPIO toggle examples.

    To get this to work, I think what you need to do is connect all the above pins to GPIO pins on the F28027 and then write some drivers toggle these GPIO based on your application need.

    For connecting GPIO:

    Note that GPIO are broken into two ports, A:GPIO0 to 31 and B:GPIO32 to 63 (not every GPIO of port A and most GPIO of B are not actually pinned out).  It may make your drivers easier to write if you keep things that will be written at the same time on the same port, and better yet if you can keep multi-bit operations on consecutive GPIO on the same port.

    e.g. If you put your "8-bit data input" on GPIO0 to GPIO7, you can just mask the upper 24 bits during read-modify-write operation.  If the 8 bits are distributed to random GPIO, you may need large amounts of code to do bit packing (many mask, shift, and combine operations). Actually using these 8 GPIO may not be possible if you need to use any of the ePWM modules (which are also on those 8 pins), but in general selecting contiguous GPIO as much as possible will simplify things.  

    To write your drivers, I suggest you make a set of functions that represent the physical operations possible to the synthesizer (e.g. Write 8 bit data, toggle reset, etc.) then fill these in with the appropriate GPIO manipulations.  Once these work, you can combine them into higher level functional drivers (e.g. initialize device, set frequency, etc.)

  • Hi Devin,

    Thank you very much for the last response.

    I  have few questions:

    1) Should I start with the example code: 'Example_F2802xLEDBlink' because I am having problems with creating separate 'inlcudes' files and header files.

    2) Or should I start from the blank? However, I need some guidance to do so.

  • Hi Aidyn,

    I think it is almost always easier to start with a working project and incrementally add/rename as desired.

    I would recommend that if you are having trouble adding include and/or source files to the project to create a new thread with more specifics. 

  • Hi Devin,

    Thank you very much for helping! I really appreciate it!

    However, I still cannot make it work.

    If it is possible, could you type the approx code here, please? 

    I am redesigning the F2802xBlinkLed example project.

    Basically, I want to change the MCU: Arduino to F28027 launchpad.

    Below is the Arduino code (MCU running the DDS): 

    #define W_CLK 8 // Pin 8 - connect to AD9851 module word load clock pin (CLK)
    #define FQ_UD 9 // Pin 9 - connect to freq update pin (FQ)
    #define DATA 10 // Pin 10 - connect to serial data load pin (DATA)
    #define RESET 11 // Pin 11 - connect to reset pin (RST).

    #define pulseHigh(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); }

    // transfers a byte, a bit at a time, LSB first to the 9851 via serial DATA line
    void tfr_byte(byte data)
    {
    for (int i=0; i<8; i++, data>>=1) {
    digitalWrite(DATA, data & 0x01);
    pulseHigh(W_CLK); //after each bit sent, CLK is pulsed high
    }
    }

    // frequency calc from datasheet page 8 = <sys clock> * <frequency tuning word>/2^32
    void sendFrequency(double frequency) {
    int32_t freq = (frequency * 4294967296.0)/(180.0e6 * 0.1626); // note 180 MHz clock on 9851
    for (int b=0; b<4; b++, freq>>=8) {
    tfr_byte(freq & 0xFF);
    }
    tfr_byte(0x000); // Final control byte, all 0 for 9851 chip
    pulseHigh(FQ_UD); // Done! Should see output
    }

    void setup() {
    // configure arduino data pins for output
    pinMode(FQ_UD, OUTPUT);
    pinMode(W_CLK, OUTPUT);
    pinMode(DATA, OUTPUT);
    pinMode(RESET, OUTPUT);

    pulseHigh(RESET);
    pulseHigh(W_CLK);
    pulseHigh(FQ_UD); // this pulse enables serial mode - Datasheet page 12 figure 10
    }

    void loop() {
    sendFrequency(100.0e3); // freq
    while(1);
    }

  • Aidyn,

    I think this will be easier than I previously mentioned because it looks like everything in your code is serial (so no need to find groups of GPIO together).

    Check out and try to understand the Example_2802xGpioSetup.c example.  This will show you how to configure and write to individual pins.  e.g. to make GPIO6 go high:

    GPIO_setHigh(myGpio, GPIO_Number_6);

    Note that this will only work if that GPIO is configured as an output (this is also demonstrated in the example).  

    To make the same pin go low, you can use

    GPIO_setLow(myGpio, GPIO_Number_6);

    So just pick some GPIO pins(looks like you need 4) , set them as outputs, and then use the functions above to make the pins toggle as per the Arduino code.  

  • Devin,

    Thank you for your response.

    Here is my following code which does not work.

    Could you help me to modify it, please? Also, I could find the XRS (reset) pin.

    //#############################################################################
    //
    // File: f2802x_examples_ccsv4/timed_led_blink/Example_F2802xLedBlink.c
    //
    // Title: F2802x LED Blink Getting Started Program.
    //
    // Group: C2000
    // Target Device: TMS320F2802x
    //
    //! \addtogroup example_list
    //! <h1>LED Blink</h1>
    //!
    //! This example configures CPU Timer0 for a 500 msec period, and toggles
    //! the GPIO0-4 LEDs once per interrupt. For testing purposes, this example
    //! also increments a counter each time the timer asserts an interrupt.
    //!
    //! Watch Variables
    //! - interruptCount
    //!
    //! Monitor the GPIO0-4 LEDs blink on (for 500 msec) and off (for 500 msec)
    //! on the 2802x0 control card.
    //
    // (C) Copyright 2012, Texas Instruments, Inc.
    //#############################################################################
    // $TI Release: f2802x Support Library v200 $
    // $Release Date: Tue Jul 24 10:01:39 CDT 2012 $
    //#############################################################################

    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File

    #include "f2802x_common/include/adc.h"
    #include "f2802x_common/include/clk.h"
    #include "f2802x_common/include/flash.h"
    #include "f2802x_common/include/gpio.h"
    #include "f2802x_common/include/pie.h"
    #include "f2802x_common/include/pll.h"
    #include "f2802x_common/include/timer.h"
    #include "f2802x_common/include/wdog.h"

    // Prototype statements for functions found within this file.
    interrupt void cpu_timer0_isr(void);

    uint16_t interruptCount = 0;

    ADC_Handle myAdc;
    CLK_Handle myClk;
    FLASH_Handle myFlash;
    GPIO_Handle myGpio;
    PIE_Handle myPie;
    TIMER_Handle myTimer;

    void main(void)
    {

    CPU_Handle myCpu;
    PLL_Handle myPll;
    WDOG_Handle myWDog;

    // Initialize all the handles needed for this application
    myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
    myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
    myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
    myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
    myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
    myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
    myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
    myTimer = TIMER_init((void *)TIMER0_BASE_ADDR, sizeof(TIMER_Obj));
    myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));

    // Perform basic system initialization
    WDOG_disable(myWDog);
    CLK_enableAdcClock(myClk);
    (*Device_cal)();

    //Select the internal oscillator 1 as the clock source
    CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

    // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2
    PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2);

    // Disable the PIE and all interrupts
    PIE_disable(myPie);
    PIE_disableAllInts(myPie);
    CPU_disableGlobalInts(myCpu);
    CPU_clearIntFlags(myCpu);

    // If running from flash copy RAM only functions to RAM
    #ifdef _FLASH
    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    #endif

    // Setup a debug vector table and enable the PIE
    PIE_setDebugIntVectorTable(myPie);
    PIE_enable(myPie);

    // Register interrupt handlers in the PIE vector table
    PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_7, (intVec_t)&cpu_timer0_isr);

    // Configure CPU-Timer 0 to interrupt every 500 milliseconds:
    // 60MHz CPU Freq, 50 millisecond Period (in uSeconds)
    // ConfigCpuTimer(&CpuTimer0, 60, 500000);
    TIMER_stop(myTimer);
    TIMER_setPeriod(myTimer, 50 * 500000);
    TIMER_setPreScaler(myTimer, 0);
    TIMER_reload(myTimer);
    TIMER_setEmulationMode(myTimer, TIMER_EmulationMode_StopAfterNextDecrement);
    TIMER_enableInt(myTimer);

    TIMER_start(myTimer);

    //Aidyn
    GPIO_setPullUp(myGpio, GPIO_Number_4, GPIO_PullUp_Enable); ///////freq update
    GPIO_setPullUp(myGpio, GPIO_Number_5, GPIO_PullUp_Enable); ///////reset
    GPIO_setPullUp(myGpio, GPIO_Number_6, GPIO_PullUp_Enable); ///////data
    GPIO_setPullUp(myGpio, GPIO_Number_18, GPIO_PullUp_Enable); ///////wclk


    // Configure GPIO 0-3 as outputs
    GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
    GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose);
    GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose);
    GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose);
    //Aidyn
    GPIO_setMode(myGpio, GPIO_Number_18, GPIO_18_Mode_XCLKOUT); ///////////////wclk
    GPIO_setMode(myGpio, GPIO_Number_4, GPIO_0_Mode_GeneralPurpose); ///////freq update
    GPIO_setMode(myGpio, GPIO_Number_5, GPIO_0_Mode_GeneralPurpose); ///////reset
    GPIO_setMode(myGpio, GPIO_Number_6, GPIO_0_Mode_GeneralPurpose); ///////data

    GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);
    GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output);
    GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);
    GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);
    //Aidyn
    GPIO_setDirection(myGpio, GPIO_Number_18, GPIO_18_Mode_XCLKOUT); ///////////wclk
    GPIO_setDirection(myGpio, GPIO_Number_4, GPIO_Direction_Output); /////freq update
    GPIO_setDirection(myGpio, GPIO_Number_5, GPIO_Direction_Output); /////reset
    GPIO_setDirection(myGpio, GPIO_Number_6, GPIO_Direction_Output); ////data output

    GPIO_setLow(myGpio, GPIO_Number_0);
    GPIO_setHigh(myGpio, GPIO_Number_1);
    GPIO_setLow(myGpio, GPIO_Number_2);
    GPIO_setHigh(myGpio, GPIO_Number_3);
    //Aidyn
    GPIO_setHigh(myGpio, GPIO_Number_18); ///////////wclk
    GPIO_setHigh(myGpio, GPIO_Number_4); /////freq update
    GPIO_setHigh(myGpio, GPIO_Number_5); ////reset

    // Enable CPU INT1 which is connected to CPU-Timer 0:
    CPU_enableInt(myCpu, CPU_IntNumber_1);

    // Enable TINT0 in the PIE: Group 1 interrupt 7
    PIE_enableTimer0Int(myPie);

    // Enable global Interrupts and higher priority real-time debug events
    CPU_enableGlobalInts(myCpu);
    CPU_enableDebugInt(myCpu);


    for(;;){
    asm(" NOP");
    }

    }
    ///////////////////////////////////MY TRY TO CODE//////////////////////////
    // Example of the BitConverter.GetBytes( int ) method.
    using System;

    class GetBytesInt32Demo
    {
    const string formatter = "{0,16}{1,20}";

    // Convert an int argument to a byte array and display it.
    public static void GetBytesInt32( int argument )
    {
    byte[ ] byteArray = BitConverter.GetBytes( argument );
    Console.WriteLine( formatter, argument,
    BitConverter.ToString( byteArray ) );
    }
    }


    void tfr_byte (GetBytesInt32(data)) {
    int i=0;
    for (i=0; i<8; i++, data >=1) {
    digitalWrite (GPIO_Number_6, data & 0x01);
    pulseHigh (GPIO_Number_18);
    }
    }

    void sendFreq(double frequency) {
    int b=0;
    int32_t freq = (frequency *4294967296.0)/(180.0e6);
    for ( b = 0; b<4; b++, freq >>=8) {
    tfr_byte(freq & 0xFF);
    }
    tfr_byte(0x000); // Final control byte, all 0 for 9851 chip
    pulseHigh(GPIO_Number_4); // Done! Should see output
    }
    void loop() {
    sendFrequency(100.0e3); // freq input
    while(1);
    }
    ////////////////////////////////////////////////////////////
    interrupt void cpu_timer0_isr(void)
    {
    interruptCount++;

    // Toggle GPIOs
    GPIO_toggle(myGpio, GPIO_Number_0);
    GPIO_toggle(myGpio, GPIO_Number_1);
    GPIO_toggle(myGpio, GPIO_Number_2);
    GPIO_toggle(myGpio, GPIO_Number_3);
    //Aidyn
    GPIO_toggle(myGpio, GPIO_Number_18);
    GPIO_toggle(myGpio, GPIO_Number_4);
    GPIO_toggle(myGpio, GPIO_Number_5);
    GPIO_toggle(myGpio, GPIO_Number_6);


    // Acknowledge this interrupt to receive more interrupts from group 1
    PIE_clearInt(myPie, PIE_GroupNumber_1);
    }


    //===========================================================================
    // No more.
    //===========================================================================

     

  • This is my current code:

    I have problems with pinning, I think. When I pin, the code stops working.

    I pinned the following:

           Picollo              DDS chip

    J2:       pin# 5          RESET

                 pin# 1 GND

                 pin# 8         DATA

    J1:       pin# 1  +3.3V

                 pin# 5         RESET

                 pin# 7         WCLK  

     

    Please, help me.

    //#############################################################################
    //
    // File: f2802x_examples_ccsv4/timed_led_blink/Example_F2802xLedBlink.c
    //
    // Title: F2802x LED Blink Getting Started Program.
    //
    // Group: C2000
    // Target Device: TMS320F2802x
    //
    //! \addtogroup example_list
    //! <h1>LED Blink</h1>
    //!
    //! This example configures CPU Timer0 for a 500 msec period, and toggles 
    //! the GPIO0-4 LEDs once per interrupt. For testing purposes, this example
    //! also increments a counter each time the timer asserts an interrupt.
    //!
    //! Watch Variables
    //! - interruptCount
    //!
    //! Monitor the GPIO0-4 LEDs blink on (for 500 msec) and off (for 500 msec) 
    //! on the 2802x0 control card.
    //
    // (C) Copyright 2012, Texas Instruments, Inc.
    //#############################################################################
    // $TI Release: f2802x Support Library v200 $
    // $Release Date: Tue Jul 24 10:01:39 CDT 2012 $
    //#############################################################################

    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File

    #include "f2802x_common/include/adc.h"
    #include "f2802x_common/include/clk.h"
    #include "f2802x_common/include/flash.h"
    #include "f2802x_common/include/gpio.h"
    #include "f2802x_common/include/pie.h"
    #include "f2802x_common/include/pll.h"
    #include "f2802x_common/include/timer.h"
    #include "f2802x_common/include/wdog.h"


    // Prototype statements for functions found within this file.
    interrupt void cpu_timer0_isr(void);
    void tobyte (int j, char* c);
    void tfr_byte ( int data );
    void sendFrequency(double frequency);

    uint16_t interruptCount = 0;

    ADC_Handle myAdc;
    CLK_Handle myClk;
    FLASH_Handle myFlash;
    GPIO_Handle myGpio;
    PIE_Handle myPie;
    TIMER_Handle myTimer;

    void main(void)
    {

    CPU_Handle myCpu;
    PLL_Handle myPll;
    WDOG_Handle myWDog;

    // Initialize all the handles needed for this application 
    myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
    myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
    myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
    myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
    myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
    myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
    myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
    myTimer = TIMER_init((void *)TIMER0_BASE_ADDR, sizeof(TIMER_Obj));
    myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));

    // Perform basic system initialization 
    WDOG_disable(myWDog);
    CLK_enableAdcClock(myClk);
    (*Device_cal)();

    //Select the internal oscillator 1 as the clock source
    CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

    // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2
    PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2);

    // Disable the PIE and all interrupts
    PIE_disable(myPie);
    PIE_disableAllInts(myPie);
    CPU_disableGlobalInts(myCpu);
    CPU_clearIntFlags(myCpu);

    // If running from flash copy RAM only functions to RAM 
    #ifdef _FLASH
    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    #endif

    // Setup a debug vector table and enable the PIE
    PIE_setDebugIntVectorTable(myPie);
    PIE_enable(myPie);

    // Register interrupt handlers in the PIE vector table
    PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_7, (intVec_t)&cpu_timer0_isr);

    // Configure CPU-Timer 0 to interrupt every 500 milliseconds:
    // 60MHz CPU Freq, 50 millisecond Period (in uSeconds)
    // ConfigCpuTimer(&CpuTimer0, 60, 500000);
    TIMER_stop(myTimer);
    TIMER_setPeriod(myTimer, 50 * 500000);
    TIMER_setPreScaler(myTimer, 0);
    TIMER_reload(myTimer);
    TIMER_setEmulationMode(myTimer, TIMER_EmulationMode_StopAfterNextDecrement);
    TIMER_enableInt(myTimer);

    TIMER_start(myTimer);

    //Aidyn
    GPIO_setPullUp(myGpio, GPIO_Number_4, GPIO_PullUp_Enable); ///////freq update
    GPIO_setPullUp(myGpio, GPIO_Number_5, GPIO_PullUp_Enable); ///////reset
    GPIO_setPullUp(myGpio, GPIO_Number_6, GPIO_PullUp_Enable); ///////data
    GPIO_setPullUp(myGpio, GPIO_Number_18, GPIO_PullUp_Enable); ///////wclk


    // Configure GPIO 0-3 as outputs
    GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
    GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose);
    GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose);
    GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose);
    //Aidyn
    GPIO_setMode(myGpio, GPIO_Number_18, GPIO_18_Mode_XCLKOUT); ///////////////wclk
    GPIO_setMode(myGpio, GPIO_Number_4, GPIO_0_Mode_GeneralPurpose); ///////freq update
    GPIO_setMode(myGpio, GPIO_Number_5, GPIO_0_Mode_GeneralPurpose); ///////reset
    GPIO_setMode(myGpio, GPIO_Number_6, GPIO_0_Mode_GeneralPurpose); ///////data

    GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);
    GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output);
    GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);
    GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);
    //Aidyn
    GPIO_setDirection(myGpio, GPIO_Number_18, GPIO_18_Mode_XCLKOUT); ///////////wclk
    GPIO_setDirection(myGpio, GPIO_Number_4, GPIO_Direction_Output); /////freq update
    GPIO_setDirection(myGpio, GPIO_Number_5, GPIO_Direction_Output); /////reset
    GPIO_setDirection(myGpio, GPIO_Number_6, GPIO_Direction_Output); ////data output

    GPIO_setLow(myGpio, GPIO_Number_0);
    GPIO_setHigh(myGpio, GPIO_Number_1);
    GPIO_setLow(myGpio, GPIO_Number_2);
    GPIO_setHigh(myGpio, GPIO_Number_3);
    //Aidyn
    GPIO_setHigh(myGpio, GPIO_Number_18); ///////////wclk
    GPIO_setHigh(myGpio, GPIO_Number_4); /////freq update
    GPIO_setHigh(myGpio, GPIO_Number_5); ////reset

    // Enable CPU INT1 which is connected to CPU-Timer 0:
    CPU_enableInt(myCpu, CPU_IntNumber_1);

    // Enable TINT0 in the PIE: Group 1 interrupt 7
    PIE_enableTimer0Int(myPie);

    // Enable global Interrupts and higher priority real-time debug events
    CPU_enableGlobalInts(myCpu);
    CPU_enableDebugInt(myCpu);


    for(;;){
    asm(" NOP");
    }

    }
    ///////////////////////////////////MY TRY TO CODE//////////////////////////

    void tobyte (int j, char* c) {

    c=(char*)(((int)'0')+j);

    }


    ////////////////////////////////////////////////////////////////////////////
    void tfr_byte ( data ) {
    int i;
    char byte;
    tobyte (data, &byte);
    for (i=0; i<8; i++, data >=1) {

    if ((data & 0x01) == 1) {
    GPIO_setHigh (myGpio, GPIO_Number_6);
    }
    if ((data & 0x01) == 0) {
    GPIO_setLow (myGpio, GPIO_Number_6);
    }
    GPIO_setHigh (myGpio, GPIO_Number_18);
    }
    }

    void sendFrequency(double frequency) {
    int b=0;
    int32_t freq = (frequency *4294967296.0)/(180.0e6);
    for ( b = 0; b<4; b++, freq >>=8) {
    tfr_byte(freq & 0xFF);
    }
    tfr_byte(0x000); // Final control byte, all 0 for 9851 chip
    GPIO_setHigh(myGpio, GPIO_Number_4); // Done! Should see output
    }
    void loop() {
    sendFrequency(100.0e3); // freq input
    while(1);
    }


    ////////////////////////////////////////////////////////////
    interrupt void cpu_timer0_isr(void)
    {
    interruptCount++;

    // Toggle GPIOs
    GPIO_toggle(myGpio, GPIO_Number_0);
    GPIO_toggle(myGpio, GPIO_Number_1);
    GPIO_toggle(myGpio, GPIO_Number_2);
    GPIO_toggle(myGpio, GPIO_Number_3);
    //Aidyn; think about this
    GPIO_toggle(myGpio, GPIO_Number_18);
    GPIO_toggle(myGpio, GPIO_Number_4);
    GPIO_toggle(myGpio, GPIO_Number_5);
    GPIO_toggle(myGpio, GPIO_Number_6);


    // Acknowledge this interrupt to receive more interrupts from group 1
    PIE_clearInt(myPie, PIE_GroupNumber_1);
    }


    //===========================================================================
    // No more.
    //===========================================================================