cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

I made a very simple test jig , where the system clock is set to 48MHz, no dividers.  I am simply toggling a pin.

   

int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

   

    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
    for(;;)
    {
        SCLK_Write(0x01);
        SCLK_Write(0x00);
        /* Place your application code here. */
    }
}

   

but I am not seeing the pin toggle at nearly the rate I would expect given the system clock speed.  Frequency of the output is 350kHz, so it is 48MHz/350kHz = 137 off from 48MHz.  I have a hard time believing that there are so many cycles per instruction.   Rather, I am thinking something is not configured quite right in my project.  What could it be?

   

Also, why is there a question mark under Desired for Sysclk?

0 Likes
8 Replies
rola_264706
Honored Contributor II
        Try this to speed it up CY_SYS_PINS_SET_PIN(Pin_Test__DR, Pin_Test_SHIFT); /* Clear TestPin */ CY_SYS_PINS_CLEAR_PIN(Pin_Test__DR, Pin_Test_SHIFT); /* do it again */ CY_SYS_PINS_SET_PIN(Pin_Test__DR, Pin_Test_SHIFT); CY_SYS_PINS_CLEAR_PIN(Pin_Test__DR, Pin_Test_SHIFT); This speeds it up from 20 clock cycles to 7 clock cycles.   
0 Likes
Anonymous
Not applicable

This sped up the signals to 1.5Mhz, certainly better.  Is there any way to speed this up further?  Thanks

0 Likes
JoMe_264151
Expert II

I cannot see the question mark 😉

   

Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file. Also, tell us what board you used, Cypress Kit? Which one?? Self-made???

   

 

   

Bob

0 Likes
rola_264706
Honored Contributor II
0 Likes
rola_264706
Honored Contributor II

Also this Document on GPIO pin uses. http://www.cypress.com/documentation/application-notes/an86439-psoc-4-using-gpio-pins. There are also example programs for each example in the Document.

0 Likes
Anonymous
Not applicable

Attachment Added - This is a self made board. 

0 Likes
JoMe_264151
Expert II

Now I see what you mean! Toggling a pin to its maximum speed by using the CPU is of no use:

   
        
  • You have no control over the duty-cycle
  •     
  • You are burning all your MIPS
  •     
  • When interrupts fire there will be tremendous jitter
  •     
  • The clock will be always non symetric caused by the jump in the loop
  •    
   

For having a pin to output a frequency always use a PWM or a timer, you may even output a clock directly. This will avoid all the problems from above.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hii Bob:

   

That was just a test jig for evaluating speed of operation.  I was trying to determine why my bit banged spi bus was running so slowly.  It doesn't run continuously, only occasionally and I did not lay out the board to take advantage of the built in SPI driver.  I will do that on my next board spin.  Thanks

0 Likes