HCS08AW Internal Clock Enabled - Use XTAL and/or EXTAL as GPIO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HCS08AW Internal Clock Enabled - Use XTAL and/or EXTAL as GPIO

1,951 Views
ride
Contributor I
I am using a MC9S08AW16 48-QFN package with the internal clock generator.  According to the datasheet it would seem that with the internal clock enabled I should be able to use PTG5(XTAL) and PTG6(EXTAL) as GPIO.  I am using Processor Expert to initialize the clock settings.  The CLKS bits of the ICGC1 are set to 01 as desired.  Is there another register somewhere that has to be set properly for these pins to function?  I tried using a PE BitIO bean to make the pins function and also manually setting the PTG registers to get the pins to function as I/O.  I tried setting/clearing REFS and HGO in ICGC to see if that made a difference.
 
How do I or can I make PTG5 and PTG6 function as GPIO when using the Internal Clock source?
 
Thanks for any input on this.
Labels (1)
0 Kudos
5 Replies

490 Views
peg
Senior Contributor IV
Hello and welcome to the fora, ride.

There is one trap here that may be catching you. It is the fact that the FIRST write to the CLKS bits in ICGC1 determine whether or not the pins are reserved for oscillator use or not. If the first write to ICGC1 has CLKS 0:X you should be able to then use the pins as GPIO.
0 Kudos

490 Views
ProcessorExpert
Senior Contributor III
Hello ride,

The problem is that "External Clock" property in the CPU bean (in "Properties" tab) is enabled as default  therefore the CPU bean allocates PTG6_XTAL pin as a external source and then there is no possibility to use it in BitIO bean (You see an error in the BitIO bean).

To avoid your problem please disable the "External Clock" property in the CPU bean.

Unfortunately the error in the BitIO bean has not exactly information what the user should exactly do in this situation. We will improve it in the next release of Processor Expert.

best regards
Vojtech Filip
Processor Expert Support Team
UNIS

0 Kudos

490 Views
ride
Contributor I
Vojtech,
 
Thanks for the reply.  I have disabled the external clock in the CPU bean.  So I don't get an error for the BITIO bean.  I setup a test project where I did nothing but intialize the CPU to run the internal clock disabling the external clock output and then attempted to use BITIO bean for PTG6/EXTAL and PTG5/XTAL.  No errors are generated.  Still no function on PTG5 or PTG6.  My PCB actually uses PTG5.
 
A previous reply from Peg mentioned writing of CLKS bits in ICGC1 register being write once registers after reset.  Can it be that PE generated code is writing CLKS before the point in CPU.C _Entry_Point()?  Comments in the code here indicate that this is the right place for the write once values.  Thanks for the input.
0 Kudos

490 Views
ProcessorExpert
Senior Contributor III
Hello ride,

Could you please be more specific how you tested the pins? A project demonstrating the problem and more information about your (PCB) EVB  board will be the best. What version of CW and PE are you using? I couldn't reproduce your problem, both PTG6 and PTG5 work as expected (see the attached test project showing a square wave on PTG5 and PTG6).

There is no code before Entrypoint function. The code in Entrypoint function is executed immediately after reset. The ICGC1 is not a write once register but there are some limitations of writing into this register. For more detailed information please see the "Table8-1. ICGC1 Register Field Descriptions" in the MC9S08AW60 datasheet.

best regards
Vojtech Filip
Processor Expert Support Team
UNIS

example1.zip
Message Edited by t.dowe on 2009-10-27 11:53 AM
0 Kudos

490 Views
ride
Contributor I
Vojtech,
Thanks for the example.  I couldn't get it to build right, I am still on CW V5.1 and PE 2.98.  But regardless I found my problem.  In my code I had a piece of code that didn't preserve the state of PTG5 properly and cleared the pin on each pass through my code loop.  So even though I was setting it, it was getting cleared else where.  I was only using a multimeter to test, so I didn't see the brief state change.
 
But that aside, I tried a test very similar to what you sent me.  Just intializing the clock and pin PTG5.  I set PTG5 and used a multimeter to read the state of PTG5.  I couldn't get this to work at first.  A couple of days later it worked for me.  I suspect I may have been probing the wrong via on my PCB design.  The old put it down and come back to it later,  always helps clear things up.
 
Thanks all for the help.  Sorry this is a non-issue, just my own mistake.
 
For anyone else using the internal clock and want to use EXTAL and XTAL pins as GPIO.  It works, definitely works.
0 Kudos