AnsweredAssumed Answered

NVIC_Init() conflict

Question asked by John Hite on Jan 31, 2017
Latest reply on Jan 31, 2017 by John Hite

In the code excerpt below there appears to be contradictory settings for nvic. NVIC_IRQChannel on the lines commented

// First selection ************************** 

// Second selection **************************

 

In both calls to NVIC_Init() the address of nvic is used (&nvic). Or am I looking at this wrong?

 

Thanks,

JH

 

 

static void serial_init(void)
{
  USART_InitTypeDef usart;
  NVIC_InitTypeDef nvic;
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART8,ENABLE);
 
  USART_DeInit(DebugUart);      //UART8
 
  USART_StructInit(&usart);
  usart.USART_BaudRate = 115200;
  USART_Init(DebugUart, &usart);
  USART_Cmd(DebugUart ,ENABLE);
  USART_DMACmd(DebugUart, USART_DMAReq_Tx|USART_DMAReq_Rx, ENABLE);
 
  nvic.NVIC_IRQChannel = DMA1_Stream6_IRQn;      // First selection **************************
  nvic.NVIC_IRQChannelPreemptionPriority = 5;
  nvic.NVIC_IRQChannelSubPriority = 0;
  nvic.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&nvic);
 
  nvic.NVIC_IRQChannel = DMA1_Stream0_IRQn;      // Second selection **************************
  NVIC_Init(&nvic);
}

Outcomes