MC9S08QB8(4)

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

MC9S08QB8(4)

643 Views
JohnMcCosh
Contributor II

I am trying to get the timer to generate a 1 KHz squarewave using the output
compare function.  The timer is setup as follows:

 

// Timer1 Init  Run timer at 1 MHz  2 MHz bus clock

TPMSC = 0x01;           // select divide by 2 clock disabled

TPMMOD = 0xFFFF;  // Set modulus

TPMC0V = 0x01F4;    // Set initial half period (500)

TPMC0SC = 0x54;     // enable interrupt, toggle pin on compare

TPMSC = 0x09;         // enable timer 1us per tick bus clk / 2

 

The Timer ISR looks like this:

 

// Timer Channel 0 Interrupt

interrupt VectorNumber_Vtpmch0 void TPMCH0 (void)

{

     byte    temp;

      temp = TPMC0SC;      // Clear interrupt flag

     TPMC0SC_CH0F = 0;

     

     TPMC0V += 500;         // Schedule next interrupt

 

    //  Code to toggle another pin to test interrupt etc.

     if (PTBD_PTBD6 == 1)

     {

           PTBD_PTBD6 = 0;

     }   

    else

    {                

           PTBD_PTBD6 = 1;

    }

}

 

I would expect to see Pin 16, PTA0/KBIP0/TPMCH0/ADP0/ACMP+, or Pin 7, PTB5/TPMCH0
toggle at a 1 KHz rate depending on the setting of the SOPT2 register, bit 4. 

 

I added some test code to wiggle pin PTB6 on each interrupt to verify that the ISR and timer

setup is correct.  PTB6 wiggles at 1 KHz as expected, verifying the timer setup and ISR functionality. 

 

I have tried writing 0x00 as well as 0x10 to SOPT2 and verified that neither PTA0 or PTB5 wiggle.

 

I have also verified that neither pin is being loaded (lifted pins or parts removed).

 

I have tested two PCBs with the same result.

 

The parts I am using are the samples provided by Arrow, MC9308QB8CTG with markings:

 

MQB8  CTG  4GXG.

 

I am using Code Warrior for microcontrollers IDE version 5.9.0 with the latest service packs installed.

 

Clearly, I am missing something but don’t see it. 

 

Thanks,

John

Labels (1)
Tags (2)
0 Kudos
1 Reply

412 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi John

I already answered on the SR that you create, but in order to have the answer on the community I put it here

Thanks for your code, on it you have set the TPM on the PTA0

SOPT2   = 0x00;

But also on the ADC you have

APCTL1  = 0x01;                       // PTB0 is analog input

But this is not the PTB0 is the PTA0

Then the analog function is enable on this pin

If you want to set the PTB0 as analog you need to set the

APCTL1  = 0x04

I hope this will help you.


Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos