ISR not vectoring
ISR not vectoring. Have spent a day trying to find solution but to no avail. Not sure where I am going wrong. Code is below. I can also only get the ISR to jump to the vector table if i pause debugger and manually set the TXEIE bit, bit banging it doesn't work. The SPI is sending the data but the TX interrupt is stopping at the vector table and the system just sits there?
int intHit = 0;
int
main(void)
{
int error = false;
//Setup Clock here
//After reset Running at ~8MHz (good enough?)
//SPI setup
/* Setup Clock on Port B */
RCC->AHBENR |= (1<<18); //Enable i/o port B
RCC->APB2ENR |= (1<<12); //Enable SPI clock
/* Setup MOSI and CLK and Alternate functions for SPI Hardware on Port B */
GPIOB->MODER |= (1<<7); //PB3 set to AF0
GPIOB->MODER |= (1<<11); //PB5 set to AF0
GPIOB->ODR |= (1<<3);
GPIOB->ODR |= (1<<5);
GPIOB->OSPEEDR |= (3<<6); //PB3 to max speed
GPIOB->OSPEEDR |= (3<<10); //PB5 to max speed
/* Setup the SPI hardware to communicate with External Devices */
SPI1->CR1 |= (SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE);
SPI1->CR1 |= (2<<3); //Board Rate
SPI1->CR1 |= (SPI_CR1_CPOL); //Clock to idle high
SPI1->CR1 |= (SPI_CR1_CPHA); //Clock data on rising edge
SPI1->CR2 |= (7 <<8); //Set two 16-bit transfers
SPI1->CR1 |= (SPI_CR1_SSM); //Set slave to software control
SPI1->CR1 |= (SPI_CR1_SSI);//Set NSS to high
SPI1->CR2 |= (SPI_CR2_FRXTH);//Set NSS to high
SPI1->CR1 |= (SPI_CR1_MSTR); //Set SPI to Master
SPI2->CR2 |= (SPI_CR2_TXEIE); //Turn on TX empty interrupt
SPI1->CR1 |= (SPI_CR1_SPE); // Turn on SPI port
NVIC_EnableIRQ(SPI1_IRQn);
NVIC_SetPriority(SPI1_IRQn, 1);
SPI1->DR = 0x0000;
SPI1->DR = 0x00FF;
while(1)
;
return 0;
}
void SPI1_IRQHandler ( void )
{
NVIC_DisableIRQ(SPI1_IRQn);
SPI2->CR2 &= (SPI_CR2_TXEIE);
intHit++;
}
Thanks
Adam
Please sign in to leave a comment.
Comments
1 comment