DSPRelated.com
Forums

THS1206evm and TMS320C6711 - pwm control

Started by smprzemek August 13, 2002
Hello,

I'm a student of the University in Zielona Ga in Poland.
I have a little problem with using plug-in software for THS1206evm.
I wrote very simple program using THS1206evm with TMS320C6711 (under
CCS 1.23) which does pwm control
In this program I compare triangle with input signal (first channel
of THS1206evm device).
If input signal > triangle then the LED_1 is swiched on else the
LED_1 is swiched off.
LED_2 is swiched on/off after reading 256 samples.
I met with the following problem:
I set the freq=6 MHz (ths1206evm) so the frequency LED_2 should be
about
23.44 kHz`00kHz/256 but when I measure using osciloscope notice
that is 1 kHz.
I don't know why? I must do pwm at least about 30 kHz .
I don't know where I did mistake. Maybe I should try to use timers?
Here is my program:

#include "dc_conf.h"
#include "t1206_fn.h" #include <stdio.h>
#include <csl.h>
#include <bsl.h>
#include <bsl_led.h>
#include <irq.h>
#include <timer.h>
#include <emif.h #define BLOCK_SZ 256
TIMER_HANDLE init_timer0(unsigned int period);

void init_dsk(void);

short ad_buffer[BLOCK_SZ];
float valuef[BLOCK_SZ]; /*input signal*/
float triangle[BLOCK_SZ];
float out[BLOCK_SZ];

int change=1;
int control=1; int cnt=0;

void main(void)
{ int i;

TIMER_HANDLE hTimer;
CSL_Init();
hTimer = init_timer0(ADC1_TIM_PERIOD);
init_dsk();
dc_configure(&Ths1206_1);
TIMER_Start(hTimer);
IER=0x00000012;
LED_off(LED_ALL);

for (;;) {
for (i=0; i<BLOCK_SZ; i++) {
if (i==0) control=-control;
if (control==1) LED_on(LED_2);
if (control==-1) LED_off(LED_2);

if (i<64) {change=1;};
if (i>63&i<128) {change=2;};
if (i>127&i<192) {change=3;};
if (i>191) {change=4;};

ad_buffer[i]=ths1206_read(&Ths1206_1);
valuef[i]=(ad_buffer[i]-2048)*0.00048852-0.04;

if (change==1) triangle[i]=0.032*i-1;
if (change==2) triangle[i]=-0.032*(i-64)+1;
if (change==3) triangle[i]=0.032*(i-128)-1;
if (change==4) triangle[i]=-0.032*(i-192)+1;

if (valuef[i]>triangle[i]) {
out[i]=0;
LED_on(LED_1);
}

if (valuef[i]<triangle[i]) {
out[i]=1;
LED_off(LED_1);
}
}

}

}

Sorry for my mistakes.

Regards,
Poul