Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with interrupts in UART in dsPIC30F5011

Status
Not open for further replies.

saikiran@ees

Member level 3
Member level 3
Joined
Oct 2, 2015
Messages
58
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Hyderabad
Activity points
455
Can i use two Interrupts in the same program and How can i use timer1 interrupt in both uart and lcd display.
 

Hi,

for sure you can use many interrupts in one program.

It is a problem of software how to handle it.

***
For example you can have a timer interrrupt with an interval of 10ms.
* on every interrupt handle the UART
* use an integer counter, incremented on every interrupt. If 30 set it to 0 and perform an LCD update.

--> this results in 10ms UART handling and a display update every 30 x 10ms = 300ms.

***
If you give more detailed information on your application you will get more tailored answers.

Klaus
 

Digital Clock display in LCD and Update will given by uart by using both timer and uart interrupts.This is my program.

I wrote the code for displaying in LCD with timer interrupt,but i cant how to update the clock using uart with help of interrupts.



Thank You.
 

Hi,

Digital Clock display in LCD and Update will given by uart by using both timer and uart interrupts.This is my program.
I wrote the code for displaying in LCD with timer interrupt,but i cant how to update the clock using uart with help of interrupts.

OK. And how can we help?

We don´t know the display type, nor the interface, nor update rate.
We don´t know timing, and what timer number.
We don´t have your code.

What do you need?

Klaus
 

If I understand right, you are asking about suitable code organization and how to coordinate concurrent write accesses of periodical timer and external clock set commands to the clock variable.

The problem hasn't specifically to do with LCD display or a microcontroller type.

You should firstly specify the intended code operation. I presume it's like this: The clock can be set to a new value at any time, in your case through serial commands and should continue to count up periodically from the new setting.

It sounds like that you plan to implement the periodical update completely in the timer interrupt function, and also the decoding of serial commands and setting of new clock value in the UART receiver interrupt.

Both is possible, but not necessarily the best implementation. You could also generate a "one second" timer tick in the interrupt and update the clock in main() respectively a function called from main(). Similarly the decoding of serial commands and clock setting must necessarily happen inside the receiver interrupt. You could also receive to a FIFO buffer and parse the commands from main().

I don't say should or even must be this or that way, just mention the different options. A reasonable approach is to perform not more than necessary inside interrupts, particularly no time consuming operations. Servicing a character LCD display is e.g. time consuming, involving wait times of many milliseconds. If you do it inside an interrupt, you possibly miss other events, e.g. get an UART overflow.

A processor specific point in this regard is if it supports nested interrupts. dsPIC does, but seriously speaking, there's not the lessest reason to activate nested interrupts in this case. Instead move all time consuming operations outside the interrupts.

One point to consider is to guarantee the priority of external time sets and it's consistency. When the time is set by a serial command, the setting operation must not be corrupted by an inbetween timer interrupt. At worst case, timer interrupts can be disabled for a short moment, but usually there a better ways.
 

Thank You for the reply.I wrote the code in module wise.so i cant put the code,but i will explain clearly that what i done.
Firstly,i initialize the hour,minute,second of digital clock.second will increment due to time interrupt that wrote second++ in timer interrupt and i wrote the clock function in uart.c and finally i call the function in main.It will display the running clock in lcd.But my problem is,if press enter in terminal then timer will stop and wait for receiver interrupt i.e, take the values from receiver buffer and update the hour,minute,second in clock function and continue the running clock display in the LCD.




Thank You.
 

Hi,

It seems you didn't read my post#4.
You give insufficient information. The more informations you give the more users will answer you.


It seems you have a "busy wait" within an ISR. This is no good idea.
ISRs should be short in time.
The better solution is to set a flag within the ISR, and do some important things within the ISR.
But poll the flag in main loop, and perform a function when flag is set (and clear flag)

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top