Hallo,
ich Arbeite gerade an meiner Bachelorarbeit und will Daten mit dem
stm32f4 discovery von meinem Pc empfangen.
Als Entwicklungsumgebung verwende ich Keil 4 und die
TM32F4xx_DSP_StdPeriph_Lib_V1.3.0.
Die Daten sollen über USART3 eingelesen werden, die Daten kommen auch an
dem Rx Pin (GPIOC.11)an, hab ich mit dem Ozie überprüft.
Der Controller springt jedoch nicht in die Subroutine oder setzt das
RXNE Flag.
Das RXNEIE Flag ist gesetzt also müsste das Interrupt scharf sein.
Der Dibugger bleibt in der startup_stm hängen (Bild).
Bin Echt ein wenig ratlos, ich hoffe mir kann jemand weiter helfen.
Danke schon mal im Voraus.
Gruß
Robert
//**********************************************************************
#include <stddef.h>
#include "stm32f4xx.h"
#include "math.h"
#include <stdio.h>
int k=0;
//*************UART-INIT****************
void USART_INIT(void)
{
/* UART = UART3
Tx = Pin.C.10
Rx = Pin.C.11
BaudRate = 57600
StopBits = 2
HardwareFlowControl = NON
WordLength = 8bit
*/
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef UART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitstructure;
/* Enable GPIOC clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
/* Enable GPIOD clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Enable USART clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
/* Connect PXx to USARTx_Tx*/
GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3);
/* Connect PXx to USARTx_Rx*/
GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3);
/* Configure USART Tx as alternate function */
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* Configure USART Rx as alternate function */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_Init(GPIOC, &GPIO_InitStructure);
UART_InitStructure.USART_BaudRate = 57600;
UART_InitStructure.USART_WordLength = USART_WordLength_8b;
UART_InitStructure.USART_StopBits = USART_StopBits_2;
UART_InitStructure.USART_Parity = USART_Parity_No;
UART_InitStructure.USART_HardwareFlowControl =
USART_HardwareFlowControl_None;
UART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
/* USART Clock Initialization */
USART_ClockInitstructure.USART_Clock = USART_Clock_Enable ;
USART_ClockInitstructure.USART_CPOL =USART_CPOL_High ;
USART_ClockInitstructure.USART_LastBit = USART_LastBit_Enable;
USART_ClockInitstructure.USART_CPHA = USART_CPHA_1Edge;
/* USART configuration */
USART_Init(USART3, &UART_InitStructure);
USART_ClockInit (USART3, &USART_ClockInitstructure);
USART_ITConfig(USART3,USART_IT_RXNE,ENABLE);
/* Enable USART */
USART_Cmd(USART3, ENABLE);
}
//*************************************Interruppt***********************
***
void INTERRUPT_INIT(void)
{
NVIC_InitTypeDef NVIC_usart;
NVIC_usart.NVIC_IRQChannel = USART3_IRQn;
NVIC_usart.NVIC_IRQChannelCmd= ENABLE;
NVIC_usart.NVIC_IRQChannelPreemptionPriority = 10;
NVIC_usart.NVIC_IRQChannelSubPriority = 10;
NVIC_Init(&NVIC_usart);
}
//*************************************Main*****************************
***
int main(void)
{
SystemInit();
INTERRUPT_INIT();
USART_INIT();
while (1)
{
}
}
//**********************************************************************
***
void USART3_IRQHandler(void)
{
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
{
k++;
}
USART_ClearITPendingBit (USART3,USART_IT_RXNE);
}
> void USART3__IRQHandler(void)
void USART3_IRQHandler(void)
dummy schrieb: >> void USART3__IRQHandler(void) > > void USART3_IRQHandler(void) ???????????????????
>>> void USART3__IRQHandler(void) >> void USART3_IRQHandler(void) >??????????????????? Schau mal ganz genau hin.
k -_- Danke habs korriert aber dran lags nicht springt immer noch net rein
Ist nur eine Vermutung: Im Bild sieht das für mich so aus als ob der USART3_IRQHandler eher UART3_IRQHandler heißen sollte. Ist bei der Funktion USART3_IRQHandler eine Adresse hinterlegt bei der StdPeriph_Lib? Find das allgemein seltsam, dass bei manchen UARTx_IRQHandler steht und bei anderen wieder USARTx_IRQHandler.
Also ich habe nochmal bei mir nachgeschaut. Das mit dem USART3_IRQHandler stimmt so. Ich habe allerdings die USART-Clock nicht anderweitig initialisiert, in dem Reference Manual vom STM32F405 steht auch nicht drin, dass man dort Einstellungen vornehmen muss für eine einfache Übertragung. Procedure: 1. Enable the USART by writing the UE bit in USART_CR1 register to 1. 2. Program the M bit in USART_CR1 to define the word length. 3. Program the number of stop bits in USART_CR2. (4. Select DMA enable (DMAR) in USART_CR3 if multibuffer communication is to take place. Configure the DMA register as explained in multibuffer communication. STEP 3) 5. Select the desired baud rate using the baud rate register USART_BRR 6. Set the RE bit USART_CR1. This enables the receiver which begins searching for a start bit.
Hey Felix, danke für die Anregungen. Hab die Clock mal weg gelassen hat sich leider auch nichts geändert, der Fehler bleibt. Mittlerweile hab ich das Gefühl das es vielleicht ein Keil Problem ist bzw. mit der Startup.
Robert W. schrieb: > void USART3_IRQHandler(void) > { > if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) > { > k++; > > } > USART_ClearITPendingBit (USART3,USART_IT_RXNE); > } muss das clear nich mit ins if? Wenn ich mich recht erinnere, dauert es etwas bis das Bit zurückgesetzt wird. Ich würde folgendes probieren: void USART3_IRQHandler(void) { if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { USART_ClearITPendingBit(USART3, USART_IT_RXNE); k++; } }
>Der Dibugger bleibt in der startup_stm hängen (Bild).
Der landet doch im Default Handler.
Irgendwie setzt er void USART3_IRQHandler(void)
nicht in die Vektortabelle. Mach mal ne Map-Datei
und eine ASM Listing Datei und zeig die hier.
Bitteschon. Hoffe das sind die Richtigen Daten war mir nicht ganz sicher wie ich die ASM erstelle.
Jupp, der Handler wurde nicht genommen. Er muss heissen void USART3_IRQHandler(void) In der Map Datei steht aber ein UART3_IRQHandler 0x08000377 Thumb Code 36 main.o(.text) in main.c Das 'S' fehlt.
hey habs behoben das Pogramm macht genau was soll. Danke für die Hilfe jungs
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.
