PIC18F Error [1205] [1131]

Discussion in 'Embedded Systems and Microcontrollers' started by pmanalex, Apr 19, 2011.

  1. pmanalex

    Thread Starter New Member

    Apr 19, 2011
    2
    0
    Hello All,

    My partner and I have been developing a code on a PIC18F2525 in C using mplab IDE. We're having trouble successfully building the code in MPlab. The code is attached below:

    Code ( (Unknown Language)):
    1.  
    2. #include <p18f2525.h>                   // Specific to PIC18F2525 - can use p18cxxx for generality over all PIC MCUs
    3. #include <timers.h>                     // Timer Functions
    4.  
    5. #pragma config OSC = HS                 // High-Speed Crystal (XT can be used at 4MHz or below)
    6. #pragma config WDT = OFF                // Watchdog Timer off to inhibit program from timing out
    7. #pragma config LVP = OFF                // Low-Voltage Programming
    8. #pragma config BOREN = OFF              // Brown-out Reset
    9. #pragma config MCLRE = ON               // Master Clear
    10.  
    11. #pragma code                            // Compiles subsequent instructions into the program memory section of the MCU
    12.  
    13. void interrupt()                        // Interrupts
    14. {
    15.                                         // Timer0 Interrupt: Freq = 10 Hz (Period = 0.1 seconds)
    16.   if (INTCONbits.TMR0IF == 1)           // Timer0 Interrupt Flag
    17.   {
    18.     PORTBbits.RB0 = ~PORTBbits.RB0;     // Toggle PORTB Bit0 LED
    19.     INTCONbits.TMR0IF = 0;              // Interrupt Flag (Clear)
    20.     INTCONbits.TMR0IE = 1;              // Interrupt Enable (Re-enable)
    21.     TMR0H = 0xFE;                       // Reset the Timer Preset Count
    22.     TMR0L = 0x79;          
    23.   }
    24.  
    25.                                         // Timer1 Interrupt: Freq = 13 Hz (Period = 0.0769 seconds)
    26.   if (PIR1bits.TMR1IF == 1)             // Timer1 Interrupt Flag
    27.   {
    28.     PORTBbits.RB1 = ~PORTBbits.RB1;     // Toggle PORTB Bit1 LED
    29.     PIR1bits.TMR1IF = 0;                // Interrupt Flag (Clear)
    30.     PIE1bits.TMR1IE = 1;                // Interrupt Enable (Re-enable)
    31.     TMR1H = 0xDA;                       // Preset for Timer1 MSB Register
    32.     TMR1L = 0x70;                       // Preset for Timer1 LSB register
    33.   }
    34.  
    35. }
    36.  
    37. void main()                             // Main Loop
    38. {
    39.  
    40.   TRISB = 0x00;                         // Port B configured with all Pins (Bits) as Output
    41.   PORTB = 0;                        // Start with all Outputs Low
    42.  
    43.                                         // Timer0 Registers: Prescaler = 256 (Page 123 of PIC18 Datasheet)
    44.   T0CONbits.TMR0ON = 1;                 // Bit 7: Enables Timer0
    45.   T0CONbits.T08BIT = 0;                 // Bit 6: Timer0 is configured as a 16-Bit Timer
    46.   T0CONbits.T0CS = 1;                   // Bit 5: Timer0 Clock Source configured to Transition on T0CKI Pin
    47.   T0CONbits.T0SE = 0;                   // Bit 4: Timer0 Source Edge Select configured to increment on Low-to-High transition on T0CKI Pin
    48.   T0CONbits.PSA = 0;                    // Bit 3: Timer0 Prescaler Assignment configured as Timer0 Prescaler is Assigned
    49.   T0CONbits.PS2 = 1;                    // Bits 2-0: PS2-PS0 Prescaler Rate configured to 1:256
    50.   T0CONbits.PS1 = 1;
    51.   T0CONbits.PS0 = 1;
    52.   TMR0H = 0xFE;                         // Preset for Time Register
    53.   TMR0L = 0x79;    
    54.  
    55.  
    56.                                         // Timer1 Registers: Prescaler = 8 (Page 127 of PIC18 Datasheet)
    57.   T1CONbits.RD16 = 1;                   // Bit 7: Timer1 is configured as a 16-bit Timer
    58.   T1CONbits.T1RUN = 0;                  // Bit 6: Timer1 System Clock is derived from another source
    59.   T1CONbits.T1CKPS1 = 1;                // Bit 5-4: Timer1 Input Clock Prescale configured to 1:8
    60.   T1CONbits.T1CKPS0 = 1;       
    61.   T1CONbits.T1OSCEN = 0;                // Bit 3: Timer1 Oscillator is Shut Off
    62.   T1CONbits.T1SYNC = 0;                 // Bit 2: Timer1 External Clock Input Synchronization configured to Synchronize External Clock Inputer
    63.   T1CONbits.TMR1CS = 1;                 // Bit 1: Timer1 Clock Source configured to External Clock
    64.   T1CONbits.TMR1ON = 1;                 // Bit 0: Enables Timer1
    65.   TMR1H = 0x70;                         // Preset for Timer1 MSB register
    66.   TMR1L = 0xDA;                         // Preset for Timer1 LSB register
    67.  
    68.  
    69.  
    70.                                         // Interrupt Registers
    71.   INTCON = 0;                           // Clear the Interrupt Control Register
    72.   INTCONbits.GIE = 1;                   // Bit 7: Global Interrupt Enable configured to Enable all Unmasked Interrupts
    73.   INTCONbits.PEIE = 1;                  // Bit 6: Peripheral Interrupt Enable configured to Enable all Unmasked Peripheral Interrupts
    74.   INTCONbits.TMR0IE = 1;                // Bit 5: Timer0 Overflow Interrupt Enable configured to Enable TMR0 Overflow Interrupt
    75.   INTCONbits.TMR0IF = 0;                // Bit 2: Timer0 Overflow Interrupt Flag (Clear Timer0 Interrupt Flag)
    76.   PIE1bits.TMR1IE = 1;                  // Bit 0: Timer1 Overflow Interrupt Enable configured to Enable TMR1 Overflow Interrupt
    77.   PIR1bits.TMR1IF = 1;                  // Bit 0: Timer1 Overflow Interrupt Flag (Clear Timer1 Interrupt Flag)
    78.  
    79.  
    80.   while(1)                              // Infinite Loop
    81.   {
    82.   }
    83. }
    84.  
    The two errors we are getting include:

    ...c:52:Error [1205] unknown member 'PS2' in '__tag_107'
    ...c:52:Error [1131] type mismatch in assignment
    ...c:53:Error [1205] unknown member 'PS1' in '__tag_107'
    ...c:53:Error [1131] type mismatch in assignment
    ...c:54:Error [1205] unknown member 'PS0' in '__tag_107'
    ...c:54:Error [1131] type mismatch in assignment

    We have never had a C programming class or a PIC course, so if anyone could help us on the right track that would be much appreciated!
     
    Last edited: Apr 19, 2011
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Don't know C but had a search and maybe it should be
    T0CONbits.T0PS2 = 1;

    etc, instead of

    T0CONbits.PS2 = 0;
     
  3. pmanalex

    Thread Starter New Member

    Apr 19, 2011
    2
    0
    Awesome, so we got the code to build successfully with the T0PSx changes. However, when we uploaded to the MCU neither of the LEDs were flashing, nor did they even turn on. Any ideas on where the problem may lie?

    I know this may seem like a backwards way to approach this code as delays would be far easier to program, however it is necessary for us to solve this using interrupts.
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I'd recommend having a go with the simulator in MPLab. You can step through the code, check that the timers are incrementing, see if the interrupts are working correctly, etc.
     
  5. mjhilger

    Member

    Feb 28, 2011
    119
    16
    I'm not sure which compiler you are using. But microchip's requires you supply the jump at the interrupt vector

    Code ( (Unknown Language)):
    1. //----------------------------------------------------------------------------
    2. // High priority interrupt vector
    3. #pragma code InterruptVectorHigh = 0x08
    4. void
    5. InterruptVectorHigh (void)
    6. {
    7. _asm
    8. goto InterruptHandlerHigh //jump to interrupt routine
    9. _endasm
    10. }
    There is an example of the complete code to implement an interrupt in the MCC18/example/interrupt directory. Without completely analyzing your code, I note this missing as the first problem.
     
Loading...