cant toggle pins with analog functionality on S08

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

cant toggle pins with analog functionality on S08

ソリューションへジャンプ
712件の閲覧回数
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?

ラベル(1)
0 件の賞賛
返信
1 解決策
592件の閲覧回数
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 件の賞賛
返信
2 返答(返信)
593件の閲覧回数
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 件の賞賛
返信
592件の閲覧回数
bjarnemichelsen
Contributor I

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

0 件の賞賛
返信