Help with this PIC code

Jan 03, 2011 1 Replies

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 #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


Em 3/1/2011 16:08, eryer escreveu:

[snipped]

Get a look at

formatting link

HTH

Cesar Rabak GNU/Linux User 52247. Get counted: http://counter.li.org/

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required