Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] dsPIC30F4011 - Pinout Confusion

Status
Not open for further replies.

K33rg4t3

Full Member level 3
Joined
Aug 2, 2015
Messages
165
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Activity points
2,607
Hey
I am using dsPIC30F4011 with 16 MHz crystal.
I am using mikroC for dsPIC.
I have such code:
Code:
void main() {
      int pwm_period1;
      int i;
      ADPCFG = 0xFFFF;

      // initialize PWM 1, using scale 1, and Timer 2....
      pwm_period1 = PWM_Init(500 , 1, 1, 2);

      PWM_Start(1);

      PWM_Set_Duty(0, 1); // set current duty for PWM1
      while (1)
      {
             for(i = 0; i < pwm_period1; i++)
             {
                  Delay_ms(1);
                  PWM_Set_Duty(i, 1); // set current duty for PWM1
             }
      }
}
I have expected it to run PWM on RE0 and RE1 pins (marked as PWM in datasheet):
dsPIC30F4011_pinout.png
But the PWM is generated on pin 23 (RD0).

Why? Am I understanding the datasheet wrong? Why the non-PWM pins are PWM?
 

This is one of the reason s why you need to fully understand what is actually happening in library functions.
That device has two ways of generating a PWM output: one using one of the 4 Output Compare peripherals (which have a PWM mode) and also the Motor Control PWM module that is more complex and flexible.
I do not know the library that you are using but my guess is that for a simple PWM signal it will be using one of the Output Compare modules. From the look of your code I would say that you are using Output Compare #1 which (as per Figure 13-1 of the data sheet) will output the signal on the OC1 pin which, as you have discovered, is Pin 23 which is also RD0.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top