Problem converting Chips and Timing

Discussion in 'Embedded Systems and Microcontrollers' started by PGP_Protector, Sep 24, 2010.

  1. PGP_Protector

    Thread Starter New Member

    Sep 24, 2010
    2
    0
    Ok, I'm not getting the configuration on the Timers right, maybe someone can help me.
    Using MPLAB IDE v8.56 / MPLAB C30 C Compiler (pic30-gcc.exe) v3.24


    On the p24Fj128GA010 on a Explorer 16 Board I'm using this code to set up a PWM Output and it gives me an output with a frequency of about 1.25KHz (measured on a scope)

    Code ( (Unknown Language)):
    1.  
    2. #include <p24FJ128GA010.h>  
    3. _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & FWDTEN_OFF & ICS_PGx2)  
    4. _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)  
    5. void _ISRFAST _T3Interrupt( void){_T3IF = 0;}  
    6. int main()  
    7. {  
    8. T3CON = 0x8010;  // This is about 1.25KHz with the Debugger board running at 8MHz  
    9. PR3 = 400-1;
    10. _T3IF = 0;
    11. _T3IE = 1;
    12. OC1R = OC1RS = 200;
    13. OC1CON = 0x000E;
    14. while(1);
    15. }
    16.  
    But with this Code (same code I thought) on a p24FJ256GB210, I'm not getting any output.
    Code ( (Unknown Language)):
    1.  
    2. #include <p24FJ256GB210.h>  
    3. _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & FWDTEN_OFF & ICS_PGx2)  
    4. _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)  
    5. void _ISRFAST _T3Interrupt( void){_T3IF = 0;}  
    6. int main()  
    7. {  
    8. __builtin_write_OSCCONL (OSCCON & 0xbf);
    9. RPOR5bits.RP11R = 18;       // 18=OC1       RP11
    10. __builtin_write_OSCCONL (OSCCON | 0x40);
    11. T3CON = 0x8010;  // This is about 1.25KHz with the Debugger board running at 8MHz  
    12. PR3 = 400-1;
    13. _T3IF = 0;
    14. _T3IE = 1;
    15. OC1R =OC1RS=200;
    16. OC1CON1 = 0x000E;
    17. while(1);
    18. }
    19.  
     
  2. Potato Pudding

    Well-Known Member

    Jun 11, 2010
    684
    92
    You would have to check the data sheets because between two Microchip PICs you normally can't drop in code code without correcting ports and addressing.

    For your example, I think the data area for the 256k might start where the data for the 128k chip ended.

    But like I said - you need to check all the ports and addresses carefully against the data sheets, then check the data sheets errata and then contact microchip support to have them confirm that what you got from the data sheets and errata was accurate.

    After you have done all of that - if it still isn't working - that is when you start to worry about a PIC program port.
     
Loading...