Interrupt Driven Serial port on STM32 Discover

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
Carlos L R
Posts: 45
Joined: 28 Jun 2013 03:22

Interrupt Driven Serial port on STM32 Discover

#1 Post by Carlos L R » 13 Jul 2013 09:28

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 :o

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.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Interrupt Driven Serial port on STM32 Discover

#2 Post by filip » 15 Jul 2013 09:35

Hi,

I'm glad that you have solved this, but can you tell me what did you miss in the Help file ?

Regards,
Filip.

Carlos L R
Posts: 45
Joined: 28 Jun 2013 03:22

Re: Interrupt Driven Serial port on STM32 Discover

#3 Post by Carlos L R » 21 Jul 2013 03:31

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
Attachments
Uarthwlp.PNG
Uarthwlp.PNG (51.62 KiB) Viewed 6266 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Interrupt Driven Serial port on STM32 Discover

#4 Post by filip » 22 Jul 2013 10:36

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.

corado
Posts: 401
Joined: 28 Mar 2009 11:03

Re: Interrupt Driven Serial port on STM32 Discover

#5 Post by corado » 13 Sep 2014 21:01

great, this I search urgently .-)
It's pitty, that Mikroes ISR Assistent doesn't work for ARM at this moment :-(

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Interrupt Driven Serial port on STM32 Discover

#6 Post by filip » 15 Sep 2014 14:26

Hi,

Please, can you explain how the interrupt assistant is not working ?

Regards,
Filip.

corado
Posts: 401
Joined: 28 Mar 2009 11:03

Re: Interrupt Driven Serial port on STM32 Discover

#7 Post by corado » 15 Sep 2014 15:18

?!?
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?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Interrupt Driven Serial port on STM32 Discover

#8 Post by filip » 17 Sep 2014 14:51

Hi,

As far as I can see the interrupt assistant is working OK, please see the screenshot below.

Regards,
Filip.
Attachments
interrupt_assistant.gif
interrupt_assistant.gif (10.51 KiB) Viewed 5312 times

corado
Posts: 401
Joined: 28 Mar 2009 11:03

Re: Interrupt Driven Serial port on STM32 Discover

#9 Post by corado » 17 Sep 2014 19:09

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 ?!?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Interrupt Driven Serial port on STM32 Discover

#10 Post by filip » 18 Sep 2014 13:21

Hi,

Well, this works fine on the computers in my office.
Does it work OK for you now ?

Regards,
Filip.

corado
Posts: 401
Joined: 28 Mar 2009 11:03

Re: Interrupt Driven Serial port on STM32 Discover

#11 Post by corado » 18 Sep 2014 14:26

yes, now it's ok, but I don't know why

Post Reply

Return to “mikroPascal PRO for ARM General”