MAIN

background image

#include <inoutcfg.h>

#include <csl.h>
#include <regs.h>
#include <c6x.h>
#include "c6711dsk.h"

#include <csl_irq.h>
#include <csl_mcbsp.h>
#include <csl_timer.h>
#include <csl_edma.h>
#include <csl_cache.h>

void InoutIsr (void);
void start_timer1();
void interrupt_init();

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

Declarations */

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

unsigned int analogue_in = 0;
unsigned int analogue_out = 0;
unsigned int ad1 = 0;
unsigned int ad2 = 0;
unsigned int ledstatus = 0x07000000;

#define FCPU

150000000

/* CPU clock frequency */

#define SRATE

800000

/* data sample rate 800kHz */

#define TPRD

(FCPU/(4*2*SRATE))

/* timer period, using the clock mode */

#pragma CODE_SECTION(InoutIsr, "mycode"); /* Makes the program run from internal memory */

TIMER_Handle hTimer;

/* Handle for the timer device

*/

void main(void)
{

start_timer1();
interrupt_init();

IRQ_globalEnable();

/* enable global interrupts */

for (;;);

/* wait for an interrupt */

}

void start_timer1()
{

*(unsigned volatile int *)TIMER1_CTRL = 0x000; /* Disable output of Timer 1 */

hTimer = TIMER_open(TIMER_DEV1, TIMER_OPEN_RESET);

/* Configure the timer. */
TIMER_configArgs(hTimer,

TIMER_CTL_OF(0x000003c1),
TIMER_PRD_OF(TPRD),
TIMER_CNT_OF(0)

);

/* Start Timer 1 in clock mode */
*(unsigned volatile int *)TIMER1_CTRL = 0x3C1;

/* Finally, enable the timer which will drive everything. */
TIMER_start(hTimer);

}

void interrupt_init()
{

IRQ_map(IRQ_EVT_TINT1,8);

/* CPU to Source mapping*/

IRQ_enable(IRQ_EVT_TINT1);

/* Set the IER */

IRQ_nmiEnable();

/* Set the NMI bit */

}

void InoutIsr (void)
{

analogue_in = *(unsigned volatile int *)INTDSK_CE3;

/*data processing*/

ad1 = analogue_in & 0x0fff0000;
ad2 = analogue_in & 0x00000fff;
ad1 = ad1<<4;
ad2 = ad2<<4;
analogue_out = ad1 | ad2;

background image

/* end of data processing */

*(unsigned volatile int *)INTDSK_CE3 = analogue_out;

return;

}


Wyszukiwarka

Podobne podstrony:
Pirates of the Spanish Main Smuggler's Song
C20090551288 B9780323067942000420 main
C20090551288 B9780323067942000055 main
P000476 D Eng Main dimensions
Main (3)
C20090551288 B9780323067942000407 main
juma rx1 main SCH Rev E
1 s2 0 S0020025512001946 main
C20090551288 B9780323067942000225 main
1 s2 0 S0378382002000085 main
main sch
C20090551288 B9780323067942000432 main
C20090551288 B9780323067942000547 main
main podanie I3HATZONEHMZNWFPG7PR3QOMEONTKHMZEET5RKQ
C20090551288 B9780323067942000298 main
ZEUS PRO MAIN PART LIST
1 s2 0 S0304397599001000 main
1 s2 0 S0006291X05021595 main
1 s2 0 S0040603111000104 main 2

więcej podobnych podstron