CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC16F887 and steering mode
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
8051topic



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

PIC16F887 and steering mode
PostPosted: Sun May 02, 2010 1:55 am     Reply with quote

I test PWM in steering mode in multi pins.
Datasheet PIC16F887 - DS41291F page 146.
11.6.7 PULSE STEERING MODE
In Single Output mode, pulse steering allows any of the PWM pins to be the modulated signal. Additionally, the same PWM signal can be simultaneously available on multiple pins.


But PWM signal is only appeared in P1A, not another pin.
Code:

#include <16F887.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

void main(void)
{
   setup_timer_2(T2_DIV_BY_1, 255, 1);
   set_pwm1_duty(124);
   output_low(PIN_C2);   // Set P1A output low
   output_low(PIN_D5);   // Set P1B output low
   output_low(PIN_D6);   // Set P1C output low
   output_low(PIN_D7);   // Set P1D output low
   setup_CCP1(CCP_PWM,CCP_PWM_H_H | CCP_PULSE_STEERING_A | CCP_PULSE_STEERING_B| CCP_PULSE_STEERING_C | CCP_PULSE_STEERING_D);

   while(1)
   {}
}

Please help me.
Thanks all!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 02, 2010 12:21 pm     Reply with quote

If you suspect a bug in the compiler, then post your compiler version.
Always do this.
8051topic



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

PostPosted: Mon May 03, 2010 9:57 am     Reply with quote

My CCS version is 4.105.
Thank for your reply.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 03, 2010 12:26 pm     Reply with quote

I don't think it's setting up the pulse steering correctly. Try this code
as a work-around:
Code:

#include <16F887.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

// These are the PWM output pins for the 16F887.
#define P1A PIN_C2
#define P1B PIN_D5
#define P1C PIN_D6
#define P1D PIN_D7
 
/*
// For the 16F886.
#define P1A PIN_C2
#define P1B PIN_B2
#define P1C PIN_B1
#define P1D PIN_B4
*/

#byte PSTRCON = 0x9d

// Call this routine to set the PWM steering.  You can OR
// together the PWM steering constants from the PIC's
// header file.
void set_pulse_steering(int32 steering)
{
int8 temp;

temp = make8(steering, 3);  // Get high byte only

PSTRCON = temp;   // Setup PWM steering register

// Set the TRIS to outputs for the enabled steering pins.
// Also set the selected pins to a low level.
if(temp & 1)
   output_low(P1A);
if(temp & 2)
   output_low(P1B);
if(temp & 4)
   output_low(P1C);
if(temp & 8)
   output_low(P1D);
}


//===========================================
void main()
{
setup_timer_2(T2_DIV_BY_16, 124, 1);  // Set 1000 Hz PWM freq

set_pwm1_duty(31);  // Set PWM for 25% duty cycle

// Set up PWM so that all four outputs are active high.
setup_ccp1(CCP_PWM_H_H);

// Enable PWM output on all four pins.
set_pulse_steering( CCP_PULSE_STEERING_A |
                    CCP_PULSE_STEERING_B |
                    CCP_PULSE_STEERING_C |
                    CCP_PULSE_STEERING_D);


while(1);
}
 
8051topic



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

PostPosted: Tue May 04, 2010 9:04 am     Reply with quote

Thank you, PCM programmer.
I'll try.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 06, 2010 2:49 pm     Reply with quote

I emailed CCS about this bug today. Hopefully they will fix it in
the next version (which will be 4.108).
8051topic



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

PostPosted: Sun May 09, 2010 2:24 am     Reply with quote

I tried your code and it worked perfectly. Thank you!
For my code above, when i change CCP_PWM in
Code:
setup_CCP1(CCP_PWM,CCP_PWM_H_H | CCP_PULSE_STEERING_A | CCP_PULSE_STEERING_B| CCP_PULSE_STEERING_C | CCP_PULSE_STEERING_D);

to
Code:
setup_CCP1(CCP_PWM_H_H | CCP_PULSE_STEERING_A | CCP_PULSE_STEERING_B | CCP_PULSE_STEERING_C| CCP_PULSE_STEERING_D);

then it worked too.
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sun May 09, 2010 11:27 am     Reply with quote

Hi,
I have never used this ECCP unit yet.
Shall I understand it that Single Mode means that it outputs PWM signal either on P1A, P1B, P1C or P1D, or on some of them, or all of them?

In other words, can I use the ECCP module to make a PWM signal on P1A and then switch it to, say, P1B (and force P1A low)?

Cheers
Meereck
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 09, 2010 12:52 pm     Reply with quote

Yes, by calling the set_pulse_steering() routine shown above, you can
switch the PWM output between the four PWM pins (P1A to P1D), or any
combination of them.
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sun May 09, 2010 2:41 pm     Reply with quote

thanks,
I also noticed that having ECCP module doesn't always mean that the PIC model has got the steering feature. Or at least it is not described in its data sheet - for example 18F1220 has got the ECCP module, but the steering feature is not mentioned in the data sheet.
Am I correct?
Does anybody know how to find a 18-pin PIC (16F/18F) without opening all device data sheets? As I can see, the new 16F18xx provide steering mode

Cheers
Meereck
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 09, 2010 2:58 pm     Reply with quote

Use the Microchip Part Selector page:
http://www.microchip.com/maps/microcontroller.aspx
In the Prefix section, select PIC18F. Then in the Package section
at the bottom, select 18 pins in both sections. Then go to the top and
look at the search results.
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sun May 09, 2010 3:05 pm     Reply with quote

I know the MAPS, but I just dont know how to view all the PICs with the steering feature. I dont think it is possible.

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 09, 2010 3:08 pm     Reply with quote

Do a search like this in Google:
Quote:
site:microchip.com type:pdf "data sheet" pwm steering


Or you could do it like this, but I don't guarantee that it gets them all:
Quote:
site:microchip.com type:pdf "data sheet" "pulse steering"
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sun May 09, 2010 3:51 pm     Reply with quote

thanks for the hint,
I think I will go for 16F1826 - seems to have ECCP, steering and half-bridge features.

Regards
Meereck
8051topic



Joined: 05 Nov 2009
Posts: 7
Location: Viet Nam

View user's profile Send private message

PostPosted: Wed May 12, 2010 8:18 am     Reply with quote

Hi PCM programmer!
I see CCP_DELAY in setup_ccp1( ) function and it use to set the dead-band delay but I can't use it!
Could you show me how to use it!
Thank you!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group