Help with this PIC code

  • Follow


Hi,
i want your opinion about this code for PIC24FJ32GB002...I want to use
internal FRC for bus clock at 8MHz and obtain a PWM output at
150KHz...this is my first pic code and i can't test it (i haven't any
evalboard)...what do you think? This is my code

 #include <P24FJ32GB002.h>
 #define DEBUG

 _CONFIG2(IESO_OFF & FNOSC_FRC & POSCMOD_NONE)
 _CONFIG1(JTAGEN_OFF & ICS_PGx2 & FWDTEN_OFF)



 int main (void)
 {
	CLKDIV=0x00;	//clock divisor 0 => 8MHz

	#ifdef DEBUG
	REFOCONbits.ROEN=1;  //to see clock on REFO pin
	#endif

      //---150KHz PWM---
      OC1CON2bits.SYNCSEL=0b00000; //free running
      OC1RS=25;
      OC1R=25/2; //50% duty cycle
      OC1CON1bits.OCTSEL=0b111; //system clock
      OC1CON1bits.OCM=0b110;
      __builtin_write_OSCCONL(OSCCON & 0xBF);
      RPOR1bits.RP3R=18;
      __builtin_write_OSCCONL(OSCCON | 0x40);

     while(1);
     return 0;
 }

I've tried to test my firmware with mplab with logic analyzer, but
notihing comes out from REFO pin, so i need your opinion...what do you
think?
Thanks
0
Reply idkfaidkfaidkfa (13) 1/3/2011 6:08:41 PM

Em 3/1/2011 16:08, eryer escreveu:
> Hi,
> i want your opinion about this code for PIC24FJ32GB002...I want to use
> internal FRC for bus clock at 8MHz and obtain a PWM output at
> 150KHz...this is my first pic code and i can't test it (i haven't any
> evalboard)...what do you think? This is my code

[snipped]

Get a look at http://eng-serve.com/pic/pic_timer.html

HTH

-- 
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/
0
Reply csrabak6676 (57) 1/3/2011 7:16:43 PM


On 3 Gen, 20:16, Cesar Rabak <csra...@bol.com.br> wrote:
> Em 3/1/2011 16:08, eryer escreveu:
>
> > Hi,
> > i want your opinion about this code for PIC24FJ32GB002...I want to use
> > internal FRC for bus clock at 8MHz and obtain a PWM output at
> > 150KHz...this is my first pic code and i can't test it (i haven't any
> > evalboard)...what do you think? This is my code
>
> [snipped]
>
> Get a look athttp://eng-serve.com/pic/pic_timer.html
>
> HTH
>
> --
> Cesar Rabak
> GNU/Linux User 52247.
> Get counted:http://counter.li.org/

Thanks for answer, but PIC16F is very different from 24F: so link
isn't useful...
0
Reply idkfaidkfaidkfa (13) 1/4/2011 8:07:23 AM

2 Replies
51 Views

(page loaded in 0.073 seconds)

Similiar Articles:













7/27/2012 12:38:32 AM


Reply: