cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
santosh.shetty
Visitor
Visitor
8,735 Views
Registered: ‎09-08-2008

Problem in generating PWM output using XPS TIMER Module

Jump to solution

Hi,

I am working on Spartan 3E board with Platform Studio Version 10.1.2.

I tried to enable PWM output using the XPS Timer Module.

i tried the following configuration for timer registers

XTmrCtr_mWriteReg(TmrCtrInstancePtr->BaseAddress, 0,XTC_TCSR_OFFSET, 0x00000276);

XTmrCtr_mWriteReg(TmrCtrInstancePtr->BaseAddress, 1,XTC_TCSR_OFFSET, 0x00000276);

 

i am not getting any PWM output as of now.Can someone please suggest me a way to get it right.

0 Kudos
1 Solution

Accepted Solutions
iwalel
Xilinx Employee
Xilinx Employee
10,179 Views
Registered: ‎07-25-2008

Hi there,

 

I tried that a while ago and used the SetOptions function for that.

 


// Set Options in Timer
     XTmrCtr_SetOptions(TmrCtrInstancePtr, TIMER0, XTC_ENABLE_PWM_OPTION |XTC_EXT_COMPARE_OPTION |XTC_DOWN_COUNT_OPTION );
     XTmrCtr_SetOptions(TmrCtrInstancePtr, TIMER1, XTC_ENABLE_ALL_OPTION | XTC_ENABLE_PWM_OPTION | XTC_DOWN_COUNT_OPTION |XTC_EXT_COMPARE_OPTION );
     // Set PWM Period (TIMER0 TLR, configured as down counter)
     // ----------------------------------------------------------
     // PWM_PERIOD = (TLR0 + 2) x PLB_CLOCK_PERIOD
     // TLR = (PWM_PERIOD/PLB_CLOCK_PERIOD) -2
      // PWM_PERIOD = 25us period --> 40kHz
     // PLB_CLOCK_PERIOD = 15.385 ns --> 65MHz
     // TLR = 1625 -2 = 1622 = 0x00000656
     // ----------------------------------------------------------
    XTmrCtr_mSetLoadReg(TmrCtrInstancePtr -> BaseAddress, TIMER0, 0x00000656);
   
     // Set PWM High Time (max. is PWM_PERIOD/PLB_CLOCK_PERIOD)
     XTmrCtr_mSetLoadReg(TmrCtrInstancePtr -> BaseAddress, TIMER1, 0x000000FF);

 

This worked fine for me.

 

 

Hope that helps!

 

View solution in original post

6 Replies
iwalel
Xilinx Employee
Xilinx Employee
10,180 Views
Registered: ‎07-25-2008

Hi there,

 

I tried that a while ago and used the SetOptions function for that.

 


// Set Options in Timer
     XTmrCtr_SetOptions(TmrCtrInstancePtr, TIMER0, XTC_ENABLE_PWM_OPTION |XTC_EXT_COMPARE_OPTION |XTC_DOWN_COUNT_OPTION );
     XTmrCtr_SetOptions(TmrCtrInstancePtr, TIMER1, XTC_ENABLE_ALL_OPTION | XTC_ENABLE_PWM_OPTION | XTC_DOWN_COUNT_OPTION |XTC_EXT_COMPARE_OPTION );
     // Set PWM Period (TIMER0 TLR, configured as down counter)
     // ----------------------------------------------------------
     // PWM_PERIOD = (TLR0 + 2) x PLB_CLOCK_PERIOD
     // TLR = (PWM_PERIOD/PLB_CLOCK_PERIOD) -2
      // PWM_PERIOD = 25us period --> 40kHz
     // PLB_CLOCK_PERIOD = 15.385 ns --> 65MHz
     // TLR = 1625 -2 = 1622 = 0x00000656
     // ----------------------------------------------------------
    XTmrCtr_mSetLoadReg(TmrCtrInstancePtr -> BaseAddress, TIMER0, 0x00000656);
   
     // Set PWM High Time (max. is PWM_PERIOD/PLB_CLOCK_PERIOD)
     XTmrCtr_mSetLoadReg(TmrCtrInstancePtr -> BaseAddress, TIMER1, 0x000000FF);

 

This worked fine for me.

 

 

Hope that helps!

 

View solution in original post

santosh.shetty
Visitor
Visitor
8,700 Views
Registered: ‎09-08-2008

Hi,

It works fine! Thank you very much for the help.

 

Best regards,

santosh

0 Kudos
iwalel
Xilinx Employee
Xilinx Employee
8,691 Views
Registered: ‎07-25-2008

Cool! Glad to hear it worked for you!

 

Enjoy the magical world of PWMs :D

 

Cheers!

 

0 Kudos
weekhee
Newbie
Newbie
8,233 Views
Registered: ‎04-24-2008

Hi

I don't find the XTC_ENABLE_PWM_OPTION in the src file.

0 Kudos
santosh.shetty
Visitor
Visitor
8,185 Views
Registered: ‎09-08-2008

Hi,

Try setting like this.

 

  XTmrCtr_mWriteReg(TmrCtrInstancePtr->BaseAddress, 0,XTC_TCSR_OFFSET, 0x00000206);
  XTmrCtr_mWriteReg(TmrCtrInstancePtr->BaseAddress, 1,XTC_TCSR_OFFSET, 0x00000606);

 

Regards,

Santosh

0 Kudos
ikoria
Visitor
Visitor
6,913 Views
Registered: ‎11-24-2008

 Hi guy ^^

 

I saw there messages and i post i comment.

 

I 'll try this way tomorrow because i have some prob with mine ^^:

 

explain:

 

I try to use xps_timer/counter for generate in PWM. My way is to use bitfield structure. I writte it correctly but something strange happening.

 

blabla... volatile struc ip_name *xps_timer main { xps_timer = xil_ip_baseadress; blabla... xps_timer->TCSR0.ARHT0 = 1; xps_timer->TCSR1.ARHT1 = 1; blabla...

 

I had do the same think for others parameters but nothing happen...

 

I search whit debug mode and i saw that just ONE timer is configured...the second is IGNORED...

I don't know wath's happen...

 

Could you help me please?

 

thx.

iko

0 Kudos