Marco Facchini

BKGD/PTA4 how to normal output pin in MC9S08SH8

Discussion created by Marco Facchini on Jun 25, 2008
Latest reply on Jun 25, 2008 by David Payne
Hi Forum,
I work with a MC9S08SH8 and I finished normal pins to drive my peripheral devices in SPI. I have to use the pin that normal I use to debugging; my hardware constrain me to use BKGD how to chip select to a devices.
Fortunately, only for a small time, at the start of my system, I have to contact this peripheral devices and then nevermore. So, I think , only if I need in my firmware, I disable Debugger, I reconfigure pin BKGD/PTA4/ACMP0/MS to a normal output pin with pull-up, then I use to drive my pheripheral and at the end I reconfigure this pin how to debugger.
The problem is that it's doesn't work. When I see the signal on the scope I don't see never change on this pin.
 
My code is :
 
              DisableInterrupts;                           //    I try to disable all Interrupts 
              for(rit=0;rit<=40000;rit++){} ;           // delay
              SOPT1_BKGDPE = 0;                   // Disable debugger               
              PTADD_PTADD4 = 1;                    // configure pin PTAD4 how to output pin 
              PTAPE_PTAPE4 = 0;                     // pull-up on pin PTAD4 
                          
              PTAD_PTAD4 = 0;                         // I trigger chip select on my devices (low active)
              PTAD_PTAD1 = 0;                         //  I turn on LED( OK I see led  blinking)
              
              for(rit=0;rit<=2000;rit++){};              // delay 
              
              SPIC1_SPE = 1 ;                           // Enable SPI comunication
              while(SPIS_SPTEF == 0){};          // check buffer trasmission (is full?)
              SPID = 0b00000000;                     //  data trasmitt to pheriperals
                 
              PTAD_PTAD4 = 1;                        // I "turn off" chip select on my devices
              PTAD_PTAD1 = 1;                        // turn off LED              
              for(rit=0;rit<=3000;rit++){};            // delay   
                                  
               PTADD_PTADD4 = 0;           // reconfigure pin PTAD4 how to input pin 
               SOPT1_BKGDPE = 1;            // Enable debugger
              
               EnableInterrupts;
    
 
I forget something ? I disable debugger , enable output pin , re-enable debugger correctly?
 
Any suggestions are welcome.
Thanks a lot.
 
Gardo          

Outcomes