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:
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!
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:
Rich (BB code):
#include <p18f2525.h> // Specific to PIC18F2525 - can use p18cxxx for generality over all PIC MCUs
#include <timers.h> // Timer Functions
#pragma config OSC = HS // High-Speed Crystal (XT can be used at 4MHz or below)
#pragma config WDT = OFF // Watchdog Timer off to inhibit program from timing out
#pragma config LVP = OFF // Low-Voltage Programming
#pragma config BOREN = OFF // Brown-out Reset
#pragma config MCLRE = ON // Master Clear
#pragma code // Compiles subsequent instructions into the program memory section of the MCU
void interrupt() // Interrupts
{
// Timer0 Interrupt: Freq = 10 Hz (Period = 0.1 seconds)
if (INTCONbits.TMR0IF == 1) // Timer0 Interrupt Flag
{
PORTBbits.RB0 = ~PORTBbits.RB0; // Toggle PORTB Bit0 LED
INTCONbits.TMR0IF = 0; // Interrupt Flag (Clear)
INTCONbits.TMR0IE = 1; // Interrupt Enable (Re-enable)
TMR0H = 0xFE; // Reset the Timer Preset Count
TMR0L = 0x79;
}
// Timer1 Interrupt: Freq = 13 Hz (Period = 0.0769 seconds)
if (PIR1bits.TMR1IF == 1) // Timer1 Interrupt Flag
{
PORTBbits.RB1 = ~PORTBbits.RB1; // Toggle PORTB Bit1 LED
PIR1bits.TMR1IF = 0; // Interrupt Flag (Clear)
PIE1bits.TMR1IE = 1; // Interrupt Enable (Re-enable)
TMR1H = 0xDA; // Preset for Timer1 MSB Register
TMR1L = 0x70; // Preset for Timer1 LSB register
}
}
void main() // Main Loop
{
TRISB = 0x00; // Port B configured with all Pins (Bits) as Output
PORTB = 0; // Start with all Outputs Low
// Timer0 Registers: Prescaler = 256 (Page 123 of PIC18 Datasheet)
T0CONbits.TMR0ON = 1; // Bit 7: Enables Timer0
T0CONbits.T08BIT = 0; // Bit 6: Timer0 is configured as a 16-Bit Timer
T0CONbits.T0CS = 1; // Bit 5: Timer0 Clock Source configured to Transition on T0CKI Pin
T0CONbits.T0SE = 0; // Bit 4: Timer0 Source Edge Select configured to increment on Low-to-High transition on T0CKI Pin
T0CONbits.PSA = 0; // Bit 3: Timer0 Prescaler Assignment configured as Timer0 Prescaler is Assigned
T0CONbits.PS2 = 1; // Bits 2-0: PS2-PS0 Prescaler Rate configured to 1:256
T0CONbits.PS1 = 1;
T0CONbits.PS0 = 1;
TMR0H = 0xFE; // Preset for Time Register
TMR0L = 0x79;
// Timer1 Registers: Prescaler = 8 (Page 127 of PIC18 Datasheet)
T1CONbits.RD16 = 1; // Bit 7: Timer1 is configured as a 16-bit Timer
T1CONbits.T1RUN = 0; // Bit 6: Timer1 System Clock is derived from another source
T1CONbits.T1CKPS1 = 1; // Bit 5-4: Timer1 Input Clock Prescale configured to 1:8
T1CONbits.T1CKPS0 = 1;
T1CONbits.T1OSCEN = 0; // Bit 3: Timer1 Oscillator is Shut Off
T1CONbits.T1SYNC = 0; // Bit 2: Timer1 External Clock Input Synchronization configured to Synchronize External Clock Inputer
T1CONbits.TMR1CS = 1; // Bit 1: Timer1 Clock Source configured to External Clock
T1CONbits.TMR1ON = 1; // Bit 0: Enables Timer1
TMR1H = 0x70; // Preset for Timer1 MSB register
TMR1L = 0xDA; // Preset for Timer1 LSB register
// Interrupt Registers
INTCON = 0; // Clear the Interrupt Control Register
INTCONbits.GIE = 1; // Bit 7: Global Interrupt Enable configured to Enable all Unmasked Interrupts
INTCONbits.PEIE = 1; // Bit 6: Peripheral Interrupt Enable configured to Enable all Unmasked Peripheral Interrupts
INTCONbits.TMR0IE = 1; // Bit 5: Timer0 Overflow Interrupt Enable configured to Enable TMR0 Overflow Interrupt
INTCONbits.TMR0IF = 0; // Bit 2: Timer0 Overflow Interrupt Flag (Clear Timer0 Interrupt Flag)
PIE1bits.TMR1IE = 1; // Bit 0: Timer1 Overflow Interrupt Enable configured to Enable TMR1 Overflow Interrupt
PIR1bits.TMR1IF = 1; // Bit 0: Timer1 Overflow Interrupt Flag (Clear Timer1 Interrupt Flag)
while(1) // Infinite Loop
{
}
}
...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: