lpcware

SSP0 - want to run it Open Drain

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Wenzu on Sat Mar 05 10:02:35 MST 2011
Hi,

I'm trying to create a 'peripheral bitbanged' 16 bit serial bitstream using SSP0 driven by DMA on an LPC1769. The baudrate I need is 9600, and this is achieved.

I am trying to run the MOSI open drained, but it's still clamping at 3v3.
I need it to be open drained for a particular reason.


Am I doing something wrong in my SSP0Init ??


void SSP0Init( void )
{
  uint8_t i;
  uint16_t Dummy=Dummy;

  /* Enable AHB clock to the SSP0. */
  LPC_SC->PCONP |= (0x1<<21);

  /* Further divider is needed on SSP0 clock. Using default divided by 4 */
  LPC_SC->PCLKSEL1 &= ~(0x3<<10);
  /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
  LPC_SSP0->CPSR = 0xA; /* closest to 9600 baud on MOSI */
 
  /* P0.15~0.18 as SSP0 */
  LPC_PINCON->PINSEL0 &= ~(0x3UL<<30);
  LPC_PINCON->PINSEL0 |= (0x2UL<<30);
  LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4));
  LPC_PINCON->PINSEL1 |= ((0x2<<0)|(0x2<<2)|(0x2<<4));

  LPC_PINCON->PINMODE1 &= ~ (0x3 << 4);
  LPC_PINCON->PINMODE1 |=   (0x2 << 4);    /* P0.18 ( MOSI ) as No pull-up no pull-down */

  /* Edited as per Zero's post */
  LPC_PINCON->PINMODE_OD0 |=  (0x1UL<<18); /* P0.18 ( MOSI ) as Open Drain */

  /*  16-bit, Frame format SPI */
    LPC_SSP0->CR0 = 0xDF0F; /* and this gives me 9600 at MOSI */
 

  for ( i = 0; i < FIFOSIZE; i++ )
  {
    Dummy = LPC_SSP0->DR;        /* clear my RxFIFO */
  }
   
  /* Master mode */
  LPC_SSP0->CR1 = SSPCR1_SSE;

  return;
}
Thanks :)

Outcomes