cant toggle pins with analog functionality on S08

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

cant toggle pins with analog functionality on S08

Jump to solution
712 Views
bjarnemichelsen
Contributor I

Hi

I have a S08 demo board called DEMO9S08DZ60 where I am trying to develop some code for a display using parallel port.

The problem is that I can't toggle the pins fast enough.

If I toggle a pin with PWM functionality (for example D1), I get a fine square wave on the scope, But if I try to toggle a pin with analog functionality (for exampe A1) I will get a voltage of 2.34V instead of the square wave

I guess there is something I need to disable before using the analog pins?

 

here is my code:

  ADCSC1_ADCH = 0b11111; //disable AD module

   PTASE_PTASE1 = 0; //disable slew rate for A.1

PTAPS_PTAPS1 = 0; //disable INT pin for A.1

ACMP1SC_ACME = 0;  //disable analog compare

APCTL1 = 0x00; //disable analog

APCTL2 = 0x00;

APCTL3 = 0x00;

PTADD_PTADD1 = 1; //A.1 as output

PTDDD_PTDDD1 = 1;   //D.1 as output

PTDSE_PTDSE1 = 0; //disable slew rate for D.1

while(1)   {

PTDD_PTDD1 = 1;

PTAD_PTAD1 = 1;

for(k = 0;k < 5; k++);

PTAD_PTAD1 = 0;

PTDD_PTDD1 = 0;

for(k = 0;k < 5; k++);

     }

 

what am I missing?

Labels (1)
0 Kudos
Reply
1 Solution
592 Views
weapon
Senior Contributor I

Hi

Your code is no problem,

The issue is caused by those capacitors on each AD input pins, when one AD pin is toggled as an output port, the capacitor will be charged and uncharged alternately, if you prolong the delay, you can see the process clearly.

You can use PTB3 to have a try, the capacitor on this pin is not installed on the board.

Best Regards

XWP

View solution in original post

0 Kudos
Reply
2 Replies
593 Views
weapon
Senior Contributor I

Hi

Your code is no problem,

The issue is caused by those capacitors on each AD input pins, when one AD pin is toggled as an output port, the capacitor will be charged and uncharged alternately, if you prolong the delay, you can see the process clearly.

You can use PTB3 to have a try, the capacitor on this pin is not installed on the board.

Best Regards

XWP

0 Kudos
Reply
592 Views
bjarnemichelsen
Contributor I

Yes you are right, I missed that.. Thanks for your help.

0 Kudos
Reply