inability to set PTA4

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

inability to set PTA4

3,619 Views
delv41
Contributor I

I am attempting to simultaneously learn how to use a microcontroller and regain my long forgotten and limited knowledge of C. This exercise is in anticipation of an up-coming project using an HC08 with CodeWarrior. Not having any hardware I am working with “full chip simulation” both employing PE and not. The CPU is MC68HC908QB8.

My problem is as follows:

I am trying to set three pins on the PTA port so I can read them as if they were input (I understand that in this case I am only reading the last write). These pins are PTA3,PTA4 and PTA5. 

Regardless of how I try to set the pins, only PTA3 and PTA5 respond. Can anyone tell me why I cannot set PTA4? 

I am confident that OSC2 and KB14 ( which share the pin) are disabled, however, I am confused about AD2.

Thanks in advance.

Labels (1)
0 Kudos
9 Replies

719 Views
bigmac
Specialist III
Hello,
 
Did you check your DDRA setting - all input bits should be set to zero?
 
If you do not require ADC operation, the ADCSC register should be set to 0x1F.  Since this is the default value after a POR, you do not need to do anything unless you have previously altered this value.
 
Regards,
Mac
 
0 Kudos

719 Views
delv41
Contributor I

Thank you, bigmac, for the quick response. I confirmed your suggestions, but unfortunately I still have the problem.

0 Kudos

719 Views
mke_et
Contributor IV
Well, first I'd make sure that you are actually reading the last write, both 0 and 1 states of the write. If that's the case, then I'd bet the bit is set to output mode and you have to figure out why it's not in input mode in the DDR.

If it's not really 'tracking' your last write, but say maybe only tracking 0... could it be that your variant of the chip has to have a '1' on the output to be valid to read input? I haven't been into 08 code for a while, and I didn't think that was necessary, but I've seen other chips in the past where you have to have a '1' set on output data or the input doesn't have a pullup.

Hmm, did you check if you chip has internal pullups/pulldowns? Do they need to be set a specific way in certain modes? Sorry, but I'm just grasping here.

Mike
0 Kudos

719 Views
delv41
Contributor I

mke_et

Thank you for the response.

I am using Full Chip Simulation in CodeWarrior for the debugger and, as far as this problem is concerned, I have no actual hardware. I am stepping through the program while watching the pertinent registers.

The problem only exists when I have created the project with "Device Initialization" or "Processor Expert". Something is being set by PE that does not occur if I do everything manually.

I am still not confident with my understanding of DDR, but let me say what I am doing. I have kept DDRA (for pins 3,4,5) permanently in the Output mode. I am not, at the moment, attempting to ever read these bits, but am only monitoring them. If this is in error, I don't understand why it works for pins 3 and 5, but not for pin 4.

For example,  having previously zeroed PTA:

PTA_PTA3=0x01; works in that bit 3 sets to 1

PTA_PTA4=0x01; does nothing

PTA_PTA5=0x01; works

regardless of PTAPUE.

Len

0 Kudos

719 Views
irob
Contributor V
Did you ever solve this problem?

I'm working with an HCS908QG4, and am having similar problems with its PTA4. I thought I found the problem (this pin is shared with the background mode), but apparently have not.
0 Kudos

719 Views
delv41
Contributor I
Irob,
 
Sorry, I never solved the problem. I moved on with my project and with real hardware and it hasn't evidenced itself, i.e. the physical pin has the appropriate state.
0 Kudos

719 Views
petr
Contributor I
Hello
It seems that there is something wrong how the simulator handles the OSC2EN bit in the PTAPUE register. According to the datasheet this bit has to be cleared to enable GPIO function on PTA4. However, when you set it to 0, the PTA4 in the simulator works as you described (i.e. doesn't work). When it is set to 1 then it seems the PTA4 in the simulator works as expected. Of course Processor Expert initializes this bit to 0, as it is described in the datasheet.
Regards Petr
0 Kudos

719 Views
Alban
Senior Contributor II
Hello Petr,
 
May I kindly ask you to Submit a new Service Request through the portal, please ?
 
This way, you will have the feedback from the creating team and the ticket will be handled by both CW and PE Team when resolution is needed.
 
Many thanks for spotting this Petr !
Alban.
0 Kudos

719 Views
delv41
Contributor I
Petr,
Thank you.
0 Kudos