After one night tryng to discover, something that is totally missing from the Mikroe help, I finally have sucess in do a interrupt driver serial reception, to help others here is the code using stm32l discovery board
program UART1;
var uart_rd : byte;
procedure interrupt(); iv IVT_INT_USART1;
begin
GPIOB_ODR.B6 := not GPIOB_ODR.B6; // Toggle PORTB
IF RXNEIE_bit then // Received Data Ready to be Read
// if (UART1_Data_Ready() <> 0) then // If data is received
begin
uart_rd := UART1_Read(); // read the received data
GPIOB_ODR.B6 := not GPIOB_ODR.B6; // Toggle PORTB
RXNE_bit := 1; // ensure interrupt not pending
end;
IF TCIE_bit then // Transmission Complete
begin
GPIOB_ODR.B6 := not GPIOB_ODR.B6; // Toggle PORTB
TCIE_bit := 1;
end;
IF TXEIE_bit then // Transmit Data Register Empty
begin
GPIOB_ODR.B6 := not GPIOB_ODR.B6; // Toggle PORTB
TXEIE_bit := 1;
UART1_Write(uart_rd); // and send data via UART
end;
end;
begin
GPIO_Digital_Output(@GPIOB_BASE, _GPIO_PINMASK_ALL); // Set PORTB as digital output
UART1_Init(115200); // Initialize UART module at 56000 bps
GPIOB_ODR.B6 := not GPIOB_ODR.B6; // Toggle PORTB blue led
Delay_ms(100); // Wait for UART module to stabilize
GPIOB_ODR.B6 := not GPIOB_ODR.B6; // Toggle PORTB blue led
RXNEIE_bit := 1; // enable uart rx interrupt
TCIE_bit := 1; // enable uart Transmission Complete interrupt
TXEIE_bit := 1; // enable uart Transmit Data Register Empty
NVIC_IntEnable(IVT_INT_USART1); // enable interrupt vector
EnableInterrupts(); // enable core interrupts
UART1_Write_Text('Start');
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
while (TRUE) do // Endless loop
begin
GPIOB_ODR.B7 := not GPIOB_ODR.B7; // Toggle PORTB green led
Delay_ms(100); // Set flash rate
end;
end.
Interrupt Driven Serial port on STM32 Discover
Re: Interrupt Driven Serial port on STM32 Discover
Hi,
I'm glad that you have solved this, but can you tell me what did you miss in the Help file ?
Regards,
Filip.
I'm glad that you have solved this, but can you tell me what did you miss in the Help file ?
Regards,
Filip.
-
- Posts: 45
- Joined: 28 Jun 2013 03:22
Re: Interrupt Driven Serial port on STM32 Discover
For sure
Take a look ob the libraries uart, and tell-me just one mention that this can be made using interrupt ? I did'nt found, And discover how to do on a try and go base, Iff on the help have at leat a section telling about my develop time for sure was faster
Take a look on the atached main Uart library Screen
Take a look ob the libraries uart, and tell-me just one mention that this can be made using interrupt ? I did'nt found, And discover how to do on a try and go base, Iff on the help have at leat a section telling about my develop time for sure was faster
Take a look on the atached main Uart library Screen
- Attachments
-
- Uarthwlp.PNG (51.62 KiB) Viewed 6266 times
Re: Interrupt Driven Serial port on STM32 Discover
Hi,
The UART library routines do not use interrupts, so the user may freely implement interrupts with the library routines.
I agree that this information will benefit our users, I will pass this to our documentation editors.
Regards,
Filip.
The UART library routines do not use interrupts, so the user may freely implement interrupts with the library routines.
I agree that this information will benefit our users, I will pass this to our documentation editors.
Regards,
Filip.
Re: Interrupt Driven Serial port on STM32 Discover
great, this I search urgently .-)
It's pitty, that Mikroes ISR Assistent doesn't work for ARM at this moment
It's pitty, that Mikroes ISR Assistent doesn't work for ARM at this moment
Re: Interrupt Driven Serial port on STM32 Discover
Hi,
Please, can you explain how the interrupt assistant is not working ?
Regards,
Filip.
Please, can you explain how the interrupt assistant is not working ?
Regards,
Filip.
Re: Interrupt Driven Serial port on STM32 Discover
?!?
There is no Interrupt assisten..
Also..there is one..But normaly I know it from AVR Mikroe that I can search the IRG I want to use, and then I give a name for the Procedure..and then OK and then the Mikroe Compiler write the correct IRQ think Procedure into the code..
But for ARM...how does it work?!!?
I can give a Name for the Procedure ans klick AUTO or not...but nothing where I can see the list for the IRQ?!?
Whats my fault?
There is no Interrupt assisten..
Also..there is one..But normaly I know it from AVR Mikroe that I can search the IRG I want to use, and then I give a name for the Procedure..and then OK and then the Mikroe Compiler write the correct IRQ think Procedure into the code..
But for ARM...how does it work?!!?
I can give a Name for the Procedure ans klick AUTO or not...but nothing where I can see the list for the IRQ?!?
Whats my fault?
Re: Interrupt Driven Serial port on STM32 Discover
Hi,
As far as I can see the interrupt assistant is working OK, please see the screenshot below.
Regards,
Filip.
As far as I can see the interrupt assistant is working OK, please see the screenshot below.
Regards,
Filip.
- Attachments
-
- interrupt_assistant.gif (10.51 KiB) Viewed 5312 times
Re: Interrupt Driven Serial port on STM32 Discover
ah on,
now it works??!!?
The last three Dayd this field behind iv was Missing!?!
There only was procedure and field and then ics auto ?!?
now it works??!!?
The last three Dayd this field behind iv was Missing!?!
There only was procedure and field and then ics auto ?!?
Re: Interrupt Driven Serial port on STM32 Discover
Hi,
Well, this works fine on the computers in my office.
Does it work OK for you now ?
Regards,
Filip.
Well, this works fine on the computers in my office.
Does it work OK for you now ?
Regards,
Filip.
Re: Interrupt Driven Serial port on STM32 Discover
yes, now it's ok, but I don't know why