setting the frequency on a 18F24K20

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

setting the frequency on a 18F24K20

Post by toyman » Wed Mar 12, 2014 4:59 pm

I included the updated SETALLDIGITAL but it keeps jumping back to a line in the util.bas module
I wish I hadn't gone with the K series. Too many problems with clock settings that I fail to comprehend.

Code: Select all

DEVICE = 18F24k20

CLOCK = 8
    

// import LCD library...

INCLUDE "convert.bas"
'INCLUDE "InternalOscillator.bas"
INCLUDE "SetDigitalIO.bas"       // Include this file when we compile so that we can use keywords like 'setalldigital'
'INCLUDE "utils.bas"

       
CONST A_data(18)AS WORD =       (%00000000,       // A                
                                  %00000000,
                                  %00000000,             	
                                  %00111110,                    
                                  %01001000,                    
                                  %01001000,                    
                                  %00111110,                    
                                  %00000000,                    
                                  %00000000,                    
                                  %00000000,         
                                    //B                                       
                                  %00000000,
                                  %00000000,
                                  %01111110, 		
                                  %01001010,                               
                                  %01001010,
                                  %00110110,
                                  %00000000,
                                  %00000000)  
                               
                                
CONST Cathodes_Data(8) AS BYTE = (%11111110, %11111101, %11111011, %11110111, %11101111, %11011111, %10111111, %01111111)    

'CONST Data_array(2) AS BYTE = (%11111111, %00000000)
DIM x AS BYTE
DIM y AS BYTE
SetAllDigital                       // Make all Pins digital I/O's
TRISC = %00000000                   // Make PORTD all outputs
TRISB = %00000000 
osccon = %01100110  
 ANSEL = $00
    ANSELH = $00
    CM1CON0 = 0
    CM2CON0 = 0

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

Re: setting the frequency on a 18F24K20

Post by Jerry Messina » Wed Mar 12, 2014 5:37 pm

but it keeps jumping back to a line in the util.bas module
WHAT keeps jumping back?

Also, double-check your osc setup. It looks like you want to use the internal osc, so
look at the statements in InternalOscillator.bas for the 18F25K20, which is very similar.

Look specifically for config FOSC, and the OSCCON register setting.

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Wed Mar 12, 2014 10:31 pm

I must have the wrong internaloscilliator.bas as there is no 18F25K20 in the module. I downloaded what was over at DDIY unless I missed another similar module. I get washed out when it comes to clock settings but learning as I go.
Yes using the internal oscilliator at 8 mhz. I have been testing my code using an 18F2420.

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

Re: setting the frequency on a 18F24K20

Post by Jerry Messina » Wed Mar 12, 2014 10:57 pm

I think it's there in the download http://digital-diy.com/swordfish-module ... -pack.html

For the 2xK20, try adding
Config FOSC = INTIO67
and
OSCCON = $62

I think that'll get you the internal 8MHz osc. When setting the osc you usually have to set a CONFIG setting and an OSCCON for the newer chips.

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Wed Mar 12, 2014 11:07 pm

I added suggestion but get error cmcon $07
will go back and download suggested link

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Wed Mar 12, 2014 11:22 pm

I download a new copy of internaloscilliator.bas and yes it has the 18F25K20
Added suggestions but still a no go.Still error in the utilis.bas module cmcon $07
I have the setalldigital.bas as well. Perhaps a conflict??

Code: Select all

DEVICE = 18F24k20

CLOCK = 8
    

// import LCD library...

INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "SetDigitalIO.bas"       // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "utils.bas"
CONFIG FOSC = INTIO67  

       
CONST A_data(18)AS WORD =       (%00000000,       // A                
                                  %00000000,
                                  %00000000,             	
                                  %00111110,                    
                                  %01001000,                    
                                  %01001000,                    
                                  %00111110,                    
                                  %00000000,                    
                                  %00000000,                    
                                  %00000000,         
                                    //B                                       
                                  %00000000,
                                  %00000000,
                                  %01111110, 		
                                  %01001010,                               
                                  %01001010,
                                  %00110110,
                                  %00000000,
                                  %00000000)  
                               
                                
CONST Cathodes_Data(8) AS BYTE = (%11111110, %11111101, %11111011, %11110111, %11101111, %11011111, %10111111, %01111111)    

'CONST Data_array(2) AS BYTE = (%11111111, %00000000)
DIM x AS BYTE
DIM y AS BYTE
SetAllDigital                       // Make all Pins digital I/O's
TRISC = %00000000                   // Make PORTD all outputs
TRISB = %00000000 
osccon = $62  
' ANSEL = $00
   ' ANSELH = $00
    'CM1CON0 = 0
    'CM2CON0 = 0

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

Re: setting the frequency on a 18F24K20

Post by Jerry Messina » Thu Mar 13, 2014 9:49 am

Your compiler isn't up to date.

In previous versions, you'll find SetAllDigital() in utils.bas
The updated routine is in the file SetDigitalIO.bas.

You can either update your compiler or remove

Code: Select all

include "utils.bas"
from your main file

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Thu Mar 13, 2014 3:17 pm

I checked and I have version 2.61
Tried removing the utilis.bas and still get the cmcon$07 error.
I didn't find any reference in the setalldigital.bas to the 18f24k20 so I added it next to the 18F25K22.
I need to go back and decipher what and where this is going south.

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

Re: setting the frequency on a 18F24K20

Post by Jerry Messina » Thu Mar 13, 2014 3:36 pm

I have no clue what V2.61 is.
I didn't find any reference in the setalldigital.bas to the 18f24k20 so I added it next to the 18F25K22
That won't work.

The file you want is called SetDigitalIO.bas. You can get it here http://www.sfcompiler.co.uk/wiki/wiki-u ... italIO.zip.

Once you have that file, I've attached a copy of the latest Util.bas. Unzip it and put Utils.bas into the Library folder.
Attachments
Utils.zip
(1.17 KiB) Downloaded 256 times

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Thu Mar 13, 2014 4:02 pm

I downloaded the file you posted and will give it a try.
V2.61 is the Pickit2 software version I am showing. Went to microchip and thats the same.

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Thu Mar 13, 2014 4:43 pm

Thanks Jerry, I installed the updated modules and now I can compile.
On to a different issue. The Vpp is to low but I think I discovered issue of why.
Problem is I think is the matrix has basically no markings so I had to test etc to match with working setup. Datta sheet for these 20mm x 20mm matrix is basically non existent.

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

Re: setting the frequency on a 18F24K20

Post by Jerry Messina » Thu Mar 13, 2014 5:10 pm

V2.61 is the Pickit2 software version I am showing
I'm not sure why that matters... nowhere in this discussion was the Pickit2 mentioned.

If you're trying to use the Pickit2 to supply power to your circuit, there's a limit on how much current it can supply...
roughly 100mA or so. If you need more than that, use an external supply.

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Re: setting the frequency on a 18F24K20

Post by Jon Chandler » Fri Mar 14, 2014 12:15 am

Tears are running down my cheeks! Jerry, you should know better than to expect kind of rational troubleshooting approach from MrDEB....I mean toyman.
Jon

Check out the TAP-28 PIC Application board at http://www.clever4hire.com/throwawaypic/

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: setting the frequency on a 18F24K20

Post by toyman » Fri Mar 14, 2014 11:10 am

My mistake Jerry, You mentioned version and I mistook it for the Pickit2 software version.
As for the low Vpp, I have the board design with the matrix in right orientation but on the wrong side. I didn't mirror the matrix correctly. So when connecting the matrix I have 4 leds on thus low Vpp.

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Re: setting the frequency on a 18F24K20

Post by Jon Chandler » Fri Mar 14, 2014 6:46 pm

Hmmm...data sheets do seem to exist. Maybe it's a figment of my imagination.


Image
Jon

Check out the TAP-28 PIC Application board at http://www.clever4hire.com/throwawaypic/

Post Reply