PIC18F13k22 Bug

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Overclocked
Posts: 21
Joined: Mon Oct 13, 2008 9:53 pm
Location: CT

PIC18F13k22 Bug

Post by Overclocked » Sun Oct 05, 2014 10:58 am

Seems my last post was eaten :/ When I try and compile for a 13k22 with convert.bas and utils.bas, I get an error that says "line 455 left side cannot be" along with "identifier not declared CMCON". It points to utils.bas, but I cant edit them.

Here is the code in case anyone wants to compile it. IntOSC is just the bits for the internal osc

Code: Select all


Device = 18F13K22
Clock = 16
Include "IntOSC.bas"
Include "USART.bas"
Include "utils.bas"
Include "convert.bas"
Config FOSC = IRC

Dim
 SecondsCount As Byte,
 MinutesCount As Byte,
 HourCount As Byte,
 TMR1IE As PIE1.0, // TMR1 Interrupt Enable
 TMR1IF As PIR1.0, // TMR1 Interrupt Flag
// TMR1ON As T1CON.0, // TMR1 Count Enable
Timer1 As TMR1L.AsWord // A quick way of creating a Word Alias
 
Const 
 TMR1StartVal = $80, // User defined TMR1 starting value
 TMR1ReloadVal = TMR1StartVal + 5 
 
 
Interrupt TMR1_Interrupt()
 Save(0) // Back up system variables
    If TMR1IF = 1 Then
    TMR1IF = 0 // Clear the TMR1 Interrupt
    T1CON.0 = 0 //Turn timer 1 off
    TMR1H = $80 //Preload high byte with 128
    TMR1L = 0   // Preload Low byte with 0
    T1CON.0 = 1 // timer 1 on
    SecondsCount = SecondsCount + 1
        If SecondsCount = 60 Then
            MinutesCount= MinutesCount +1
            SecondsCount = 0
         End If  
         
        If MinutesCount = 60 Then
            HourCount = HourCount +1
            MinutesCount = 0
        End If
                  
    
    USART.Write ("Hour:",32,DecToStr(HourCount),32,"Minutes:",32,DecToStr(MinutesCount),32, "Seconds:",32,DecToStr(SecondsCount),13,10) 
    

    EndIf 
 Restore // Restore system variables
End Interrupt 
 
 
Sub TMR1_Initialize()
 TRISC.0 = 1 // If External clock, then set clock as an input
 T1CON.0 = 0 // Timer 1 off
 TMR1H = $80 //Preload with 128
 TMR1L = 0   // 
 T1CON.0 = 1 // timer 1 on
 T1CON.1 = 1 // 1 = External clock from pin RC0/T1OSO/T1CKI (on the rising edge)
             // 0 = Internal clock (FOSC/4)
    
 T1CON.2 = 0 // 1 = Do not synchronize external clock input   
 // 0 = Synchronize external clock input
 // When T1CON.1 = 0;
 // this bit is ignored.
 T1CON.3 = 1
 T1CON.4 = 0 
 T1CON.5 = 0 

 T1CON.6 = 0 
 T1CON.7 = 0
   
 TMR1IE = 1 // Enable TMR1 Interrupts

 Enable(TMR1_Interrupt) // Enable TMR1 Interrupt Handle
End Sub 

 
// Start Of Main Program...
SecondsCount = 0 //
MinutesCount = 0 
HourCount = 0
TMR1_Initialize // Setup and enable TMR1
USART.SetBaudrate(br9600) 
While True
   
     

 
Wend


Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: PIC18F13k22 Bug

Post by Jerry Messina » Sun Oct 05, 2014 1:34 pm

What exactly is in IntOSC.bas? If I comment out that include (since I don't have it) and compile, I don't get that error message.

If I had to guess, It's likely an old version of SetAllDigital is getting included that doesn't support the 13K22. Are you sure your compiler, device files, etc are up to date?

Overclocked
Posts: 21
Joined: Mon Oct 13, 2008 9:53 pm
Location: CT

Re: PIC18F13k22 Bug

Post by Overclocked » Sun Oct 05, 2014 2:13 pm

Jerry Messina wrote:What exactly is in IntOSC.bas? If I comment out that include (since I don't have it) and compile, I don't get that error message.

If I had to guess, It's likely an old version of SetAllDigital is getting included that doesn't support the 13K22. Are you sure your compiler, device files, etc are up to date?
Well I just updated and it fixed it!

Also for completion sake, the only thing in IntOsc.bas is this line "OSCCON = %01110110"

Post Reply