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.

About Interrupts please help :( :)

Status
Not open for further replies.

Pavithra89

Member level 2
Member level 2
Joined
Mar 18, 2013
Messages
53
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,695
I m designing a microcontroller to function for serial communication as well as timer to generate frequency. Whats happening is when serial communication is taking place, timer not working and vice versa.. Please help me what is wrong asap..:-?
Regards
 

For serial communication you have to use serial interrupt. There will be problems because of delays in the code. When frequency generation code is executing serial code will not work if you don't use interrupts for serial. If serial interrupt is used then if freq generation code is executing and there is a serial data send/receive then serial interrupt is called and serial communication is completed and then execution of freq generation continues.
 
Yes used serial interrupt and now what is happening is serial communication is completed and then frequency generation is taking place continuously. Is this correct method? I thought both happens simultaneously at the same time, am I wrong ??
 

both cannot happen simulataniously. timer is used only to create delays in your code. whenever there is serial communication, serial interrupt is called and during that time freq generation i.e., port toggling is stopped. ISR has more priority but timer runs on its own and when timer overflow occurs i.e., timer interrupt occurs and timer interrupt flag is set port is toggled but I don't know which has more priority i.e., serial interrupt or timer interrupt. Check the datasheet.

I don't know what the mcu does when it is executing serial interrupt and during that time if timer interrupt flag is set and I also don't know what happens if timer interrupt flag is set and at the same time serial interrupt occurs. It all depends upon the priority of the interrupts.
 
Thank you once again :)
Serial interrupt got more priority according to data sheet. Since I'm into complex programming I'm really confused!!
What I have to do is read a character using serial port and send those bits through mc to CPLD where down counter is implemented. That part is done!! :D
Next is the generated frequency from micro controller should act like a clock to CPLD to down count the bits of character entered through serial port!!!
 

Can't you use 555 to generate 1 KHz clock or some other dedicated clock generator? Do you have to generate the clock from mcu? Why do you want to do that? every ascii character is 8 bits. why you want to count the bits?
 

I'm not sure I understand this, you want to count characters using time only? Can't you just increment a variable somewhere in your code? How does that CPLD down count characters? what kind of signals does it need?

You can use a timer to generate a clock for your CPLD, but you will have to do 2 things at the same time, does your microcontroller allow that(hardware)? what kind of microcontroller are you using?
 

@Pictou She is using 8051 mcu. She needs to give clock to CPLD down counter circuit.

@Pavithra what will be the initial value of the down counter? does it count from 1000 to 0 depending upon the bits it receives.
 

jayanth.devarayanadurga asked many legitimate questions, you may want to answer him so he can help.
 

What is the problem you are having? Are you not getting freq when serial communication is happening? Are you sending ascii data from PC to MCU and then MCU send the ascii data (bits) to CPLD?
 

Character is stored in 8051 and and the bits corresponding to each character are set in port1.1 to port 1.7 (MSB-->LSB) of MC and sent to cpld as input to programmable down counter :)
for each down counter value reaching 0, I get a pulse , thats what i've done till now.!! that pulse takes different frequency for each character entered :oops:
N BTW I'm using 8051, OOPS!! I know both timer operation and serial communiaction should happen at the same time for this.. But couldn't figure out how :evil::-(

- - - Updated - - -

Initial value would be the bits of the character entered O_O.

- - - Updated - - -

Im trying to answer his questions whenever I'm free :p
 

O_O? this is 3 characters i.e., 24 bits? will you send 1 character at a time to CPLD?

Your UART receives data like 'A' (8 bits). Assign the serial read buffer to (byte size) variable like uart_rd so uart_rd will contain 'A' then place that data on output port like P2 = uart_rd (use asm code). Then data is placed at the parallel data input of the CPLD assuming P2 is connected to CPLD. Now start the clock for CPLD and it will count. You can start generation of clock after data is placed on CPLD. ;-)

If you need to read more data like a string "abcdef" then use a buffer like uart_rd[20] and after the buffer is filled then place one data like uart_rd[0] on P2 and then generate the clock then place the second data then start the clock.
 
Last edited:
Interrupts problem :(

How can two interrupts occur at same time :) I need both serial interrupt and timer interrupt occur simultaneouls and independently!! how is that possible please help :(
 

Re: Interrupts problem :(

Hello!

Just to be sure: at present your interrupts don't happen simultaneously and you want them to be
simultaneous, right?
This cannot happen.
Your processor will call the interrupt routine for the first interrupt, and depending on what you do, discard
the second one or process it after the 1st interrupt work is finished.
Beside this, a serial interrupt is by definition asynchronous and there is no way to predict when it will
happen since it comes from another device. So timer and serial cannot happen at the same time.
But if you tell us what you want to do, it might be easier to help you.

Dora.
 
Re: Interrupts problem :(

Hello!

Just to be sure: at present your interrupts don't happen simultaneously and you want them to be
simultaneous, right?
This cannot happen.
Your processor will call the interrupt routine for the first interrupt, and depending on what you do, discard
the second one or process it after the 1st interrupt work is finished.
Beside this, a serial interrupt is by definition asynchronous and there is no way to predict when it will
happen since it comes from another device. So timer and serial cannot happen at the same time.
But if you tell us what you want to do, it might be easier to help you.

Dora.

What I really want is serial communication to happen and also micro controller generate a 1KHZ frequency through a port pin .I've written the code but both not working simultaneously ;(
Regards
 

Re: Interrupts problem :(

Hello!

This is not an accurate definition.
You want the 1kHz to happen when you received a message from serial port?
Or do you want it to happen permanently, independently on whether there is a message or not?
And you should also explain why you want it to work simultaneously. As I told you
earlier, you cannot know when your uart will receive data, so you cannot know when
it will trigger an interrupt. Therefore there is no way to have a simultaneous timer.

Beside this, you don't need to use an interrupt to have 1kHz at a port pin. That's what timers are
here for. I don't know what processor you are using, but if you have hardware timers, there should
be a way to setup your timer so that it generates a 1kHz wave at one specific port pin.

Now if you want help, define your needs FULLY. What about writing a flow chart?

Dora.
 

Re: Interrupts problem :(

Did you read post 14 here https://www.edaboard.com/threads/283696/

Post the circuit you have done in CPLD. What kind of down counter is it? What does it count?

Can't you just read the serial data one character at a time using MCU and then store all the data received in an array and then send one character in the array at a time to MCU data output (CPLD data input) and then start the clocking of CPLD with MCU? After first data is counted then stop clock to CPLD then place the next data and then start the clock to CPLD.

Unless you post the circuit you have built in CPLD and its detailed working nobody can help.
 

Re: Interrupts problem :(

Hi
timer is independent of serial communication :) sorry that i did not mention them clearly before :I
Thats what my doubt was:) So I dont need a interrupt to generate frequency :D
Now how to generate them without interrupt. I had written the code without timer interrupt but timer used to take place forever and never allowing serial communication to take place :( So I just had a thought that I could make use of interrupts to make them occur independently and forever :I
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top