新手入门
- 积分
- 19
- 金钱
- 19
- 注册时间
- 2017-9-18
- 在线时间
- 4 小时
|

楼主 |
发表于 2017-9-18 23:18:24
|
显示全部楼层
出问题的代码主要函数为:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* Enable I-Cache-------------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache-------------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI1_Init();
MX_UART7_Init();
/* USER CODE BEGIN 2 */
hspi1.RxISR =spi_rx_isr;
__HAL_SPI_ENABLE_IT(&hspi1, (SPI_IT_RXNE|SPI_IT_ERR ));
__HAL_SPI_ENABLE(&hspi1);
/* SPI1_IRQn interrupt configuration */
printf("xxxxxxxxxxxx\r\nbegin\r\n");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
GPIOG->ODR ^= GPIO_PIN_14;
printf("%d\r",i);
HAL_Delay(100);
}
/* USER CODE END 3 */
}
void spi_rx_isr(SPI_HandleTypeDef *hspi)
{
//printf("+1");
#if 1
a[i]= *(__IO uint8_t *)(&SPI1->DR);
//printf("+1=%.2X\r\n",a[i]);
i++;
if(i == 72)
{
__HAL_SPI_DISABLE_IT(&hspi1, (SPI_IT_RXNE|SPI_IT_ERR ));
__HAL_SPI_DISABLE(&hspi1);
for(i=0;i<72;i++)
{
printf("%d=%.2X\r\n",i,a[i]);
}
while(1);
}
#endif
GPIOG->ODR |= GPIO_PIN_14;
} |
|