thanks for the help yikai chen sir !!
but how to control the duty cycle using the 16bit digital values i have in hand
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.
You can refer to the register settings in CC253x/4x User's Guide and do some test to control the duty cycle.
hi sir ... the code you send when i ran it it is not giving any wave in the cro ... i checked it in the pin 14 on the dk kit sir
hi sir !!!
the code is running but there is a small delay in the pulse .. like glitches where should i use the timer pgm 2 get a continuous pulse sir .. i mean should i declare it as an separate event ??
What do you mean "small delay in the pulse"? DO you have a scree capture of your PWM output?
Your PWM signal is incorrect. Please check your HW. Do you measure correct on P1.4?
THE screen short i send is by taking from the port P1_0 which is mapped to pin 6 .
the pin P1.4 is mapped to pin 14 and it is not at all giving any outouts sir
My example code is to output PWM to P0.4. Please make sure your measurement is on P0.4.
the pin p0.4 is not giving any waves sir , in P1 SMD_SOCKET_2X10 pin p0.4 is maped to pin 3 which is not giving any waves sir ... i also declared the pgm as an additional event in my pgm ..it is giving a single wave in the pin p1.0 1ly sir (the screen shot i send you) . how to get the correct waveform sir whose dutycycle can be manipulaed according to the data i got .
how can i write the timer code in the sampletemperature sensor pgm sir ?? is there any way i can do like that , i tried like this
if ( events & SAMPLETEMPERATURESENSOR_TIMER_EVT )
{ PERCFG &= (~(0x20)); // Select Timer 3 Alternative 1 location
P2SEL |=0x20;
P2DIR |= 0xC0; // Give priority to Timer 1 channel2-3
P1SEL |= BV(4); // Set P1_0 to peripheral, Timer 1,channel 2
P1DIR |= BV(4);
T3CTL &= ~0x10; // Stop timer 3 (if it was running)
T3CTL |= 0x04; // Clear timer 3
T3CTL &= ~0x08; // Disable Timer 3 overflow interrupts
T3CTL |= 0x03; // Timer 3 mode = 3 - Up/Down
T3CCTL1 &= ~0x40; // Disable channel 0 interrupts
T3CCTL1 |= 0x04; // Ch0 mode = compare
T3CCTL1 |= 0x10; // Ch0 output compare mode = toggle on compare
T3CTL &= ~0xE0; // Clear Prescaler divider value
T3CTL |= 0xA0; //Set Prescaler divider value = Tick frequency /32
T3CC0 = 128; //Set ticks = 128
// Start timer
T3CTL |= 0x10;
return ( events ^ SAMPLETEMPERATURESENSOR_TIMER_EVT );
}
and i defined SAMPLETEMPERATURESENSOR_TIMER_EVT as 0x0001
i also tried keeping the pgm in other function also , but not working sir
the code is rite sir but i think it is not executing properly !!!!!!without the code also i am getting the same signal as in the output sir
P1.4 of CC2530 is connected to P1 pin23 on SmartRF05EB. Please try to measure P1 pin3 on SmartRF05EB for PWM signal first.
yes sir i found the pin . but the signal is not at all comming sir .. .is the way i used the coding in my pgm right , thats the biggest doubt sir
yes sir i did like this also
osal_start_timerEx( zclSampleTemperatureSensor_TaskID, SAMPLETEMPERATURESENSOR_TIMER_EVT, SAMPLETEMPERATURESENSOR_REPORT_INTERVAL );
in the event of SAMPLETEMPERATURESENSOR_TIMER_EVT .. yet no out put sir
sir
is there anything else i need to do inorder to set timer in my sample temperature sensor pgm???
of course i will sir ,..
i connected the ground of the cro to ground of the debug pin and
the other terminal of the cro to the pin 3
Please read register definition for T3CC0, T3CTL, and T3CCTL0 in CC2530 user's guide and change accordingly to change duty cycle.
okey sir but the delay in thee picture is due to what pblm sir ??
is it in the timer pgm or in the event i declared the timer code sir ??
can u pl tell me how to control the duty cycle using the digital data i have ???
1. I suppose the delay is caused by your timer event. You should check it. PWM is a HW signal and it only need to start once.
2. Please read the user guide and try to change duty cycle first. However, I have no idea how to mapping your digital value to PWM duty cycle. It is application related and you suppose to find out by yourself on your HW.
sir
CAN YOU PL HELP TO ELIMINATE THE DELAY ALONE SIR .. I TRIED ... DUTY CYCLE I THINK I CAN GET SIR
Try not use event to start PWM. You can put PWM code in "if ( keys & HAL_KEY_SW_4 )" and use SW4 to trigger it.
is there any way to change the dutycycle sir ?? ?
i mean which registers should i use to change the duty cycle ???
HI SIR !
i found the following code !!
PERCFG &= ~0X40 ; set timer alternative 1 location
P2DIR = (P2DIR & ~0XC0)| 0X80 ; give priority to timer 1
P0SEL |= 0X08 ; set P0.3 to pheripheral
T1CC0L = 0XFF ; pwm signal period
T1CC0H = 0X7F ;
T1CC1L = 0X78; pwm duty cycle
T1CC1H = 0X10;
T1CCTL1 = 0X1C ;
T1CTL |= 0X0F ; divide with 128 and do up-down mode
could you please tell me in which pin of the cc2530 kit will the output wave of the pin is mapped sir
hi sir
PERCFG &= ~0X40 ; set timer alternative 1 location
P2DIR = (P2DIR & ~0XC0)| 0X80 ; give priority to timer 1
P0SEL |= 0X08 ; set P0.3 to pheripheral
T1CC0L = 0XFF ; pwm signal period
T1CC0H = 0X7F ;
T1CC1L = 0X78; pwm duty cycle
T1CC1H = 0X10;
T1CCTL1 = 0X1C ;
T1CTL |= 0X0F ; divide with 128 and do up-down mode
in this pgm how can i change the duty cycle sir ??
Yes SIR !!
when i change the values of t1cc1l and t1cc1h the waves are changing but i couldnt get the fact that how the wave is changing and all .. i thought that i can use the register t1cc1 16 bit register bt i dont think it will work sir ..
any suggestions
Not at all. I am glad you find it out. Maybe you can share your finding to benefit others.
hi sir !!
i actually used the timer code like
if ( events & SAMPLETEMPERATURESENSOR_TIMER_EVT )
{
zcldata = (int8) zclvalue ;
PERCFG &= ~0X40 ;
P2DIR = (P2DIR & ~0XC0)| 0X80 ;
P0SEL |= 0X08 ;
T1CC0L = 0XFF ;
T1CC0H = 0X7F ;
T1CC1L = 0x78 ;
T1CC1H = zcldata ;
//T1CC1 = 25 ;
T1CCTL1 = 0X1C ;
T1CTL |= 0X0F ;
osal_start_timerEx( zclSampleTemperatureSensor_TaskID, SAMPLETEMPERATURESENSOR_TIMER_EVT, SAMPLETEMPERATURESENSOR_TIMER_INTERVAL );
return ( events ^ SAMPLETEMPERATURESENSOR_TIMER_EVT );
}
and the Zzcldata will be updated by using the values from the ZC
static void zclSampleTemperatureSensor_ProcessInReportCmd( zclIncomingMsg_t *pInMsg )
{
char str[8];
zclReportCmd_t *pInTempSensorReport;
zclReportCmd_t *pOutDemandReport;
uint8 outDemandBuffer[sizeof( zclReportCmd_t ) + ( 2 * sizeof( zclReport_t ) )];
// bool send = TRUE;
pInTempSensorReport = (zclReportCmd_t *)pInMsg->attrCmd;
if ( pInTempSensorReport->attrList[0].attrID != ATTRID_MS_TEMPERATURE_MEASURED_VALUE )
{
return;
}
//srcAddr=pInMsg->srcAddr;
// endPoint=pInMsg->endPoint;
pOutDemandReport = (zclReportCmd_t *)outDemandBuffer;
// store the current temperature value sent over the air from temperature sensor
zclvalue = BUILD_UINT16(pInTempSensorReport->attrList[0].attrData[0], pInTempSensorReport->attrList[0].attrData[1]);
if (zclvalue)
{
HalLedSet ( HAL_LED_2, HAL_LED_MODE_ON );
sprintf(str, "%dC", ((uint8)zclvalue));
HalLcdWriteString(str, HAL_LCD_LINE_3);
}
else
{
HalLedSet ( HAL_LED_2, HAL_LED_MODE_OFF );
sprintf(str, "%dC", NULL);
HalLcdWriteString(str, HAL_LCD_LINE_3);
}
zcl values will be updated in this function ... what am i doing wrong sir
by changing the values in the register T1CC1H i can change the value of the duty cycle of the generated pwm sir ... so 1ly i wrote in the event function as T1CC1H = zcldata and i saved the 16 bit value in zclvalue in the zcldata as 8bit value ...
but when i run the pgm the pulse is not at all varying as i intended sir
yes sir it is changing and i am viewing the change in the lcd using the lines
if (zclvalue)
{
//zcldata = (int8)zclvalue ;
//T1CC1H = zcldata ;
HalLedSet ( HAL_LED_2, HAL_LED_MODE_ON );
sprintf(str, "%dC", ((uint8)zclvalue));
HalLcdWriteString(str, HAL_LCD_LINE_3);
}
You only map zcldata to T1CC1H and I suggest you to check if it is large enough for duty cycle change.
yes sir ,
when i write like T1CC1H = 80 or any other values the pwm wave with different dutycycle can be obtained without any pblms sir .
but when i map like T1CC1H = zcldata it is not at all working even if the zcl data value is changing
Your zclValue is uint16 but the register is byte size. You should check if it is truncate.