I'am working with at91sam7x256 and in my program the usart interrupt dosen't work correctly ! I communicatinon with atmel but it isn't fix yet.
thise is my program...pleas help me
www.4shared.com/.../usart16__2_.html
my mail :salehi.elc@gmail.com
In what way(s). precisely, does it not "work correctly" ?
What reason(s), precisely, make you think it's a chip bug rather than a bug or flaw in your software?
becuse more than 2 month I check program and diden't find any problem in it...if any body can resolve its problem I understand it doesn't production buge! perhaps this is keil compiler buge!!
i cant understand your question . can you explain more? the send and receive of my program without interrupt is good and correctly!!!
in similator of keil when i chek registry i see that the other interrupt goto the the pending mode!!! why??
oooh!! i only had a one question ..if you was in my chair and had my problem you was like me ! pleas help me :(!
I think the phrase "There are no stupid questions" has once and for all been proven false.
I think you are a little too harsh. The OP must, however, carefully read the user manual and study the multitude of examples that exist to address this problem exactly - some provided by Keil themselves.
Ali,
Let's understand this part of your post, bit by bit...
"the exact problem with this chip is with it's usart RX interrupt that only happens once."
(1) The RX interrupt is only happening once. This means that on power up prior to invoking a test of the uart, all the uart registers are setup properly for RX interrupts to occur (else you would NOT get any). Check the peripheral registers window to see how they are setup, before and after the RX interrupt occurs.
"I set all the registors related to resetting vectors in different approaches,but the problem still goes on !!"
(2) I don't know what this means. You vector to your uart interrupt handler that is located in the IVT. There is one per peripheral. If you are vectoring to your uart interrupt handler, then the vector is properly setup. No need to play with this again.
"In Atmel's sampale transmitting data is performed by interrupt timer..."
(3) OK, so you don't want to use the timer to send data. If there is no data to send and the timer is still running and loading the UART TX data register you will get garbage (whatever it's sending to the uart) out.
(4) Do not assume that is is NOT your code FIRST, regardless of how long you have worked on the problem. There are some REALLY nasty bugs that can happen (memory leaks for starters) that can take FOREVER to track down.
The simplest reason for a interrupt not firing again, if it fired correctly the first time, is because you did not clear/reset the interrupt on exit from the interrupt handler.
...is very often the most likely reason.
If it fired once, then didn't fire again, then that almost certainly means that you didn't put it back into the correct state to fire again.
thanks alot for your reply .
but i have a question about it : you say "..The simplest reason for a interrupt not firing again, if it fired correctly the first time, is because you did not clear/reset the interrupt on exit from the interrupt handler...."
Ok ... if i want reset the interrupt on exit from the irq_handler what work should I do ????what registry should write in or read from it for do it ??? do you now!!! I think that i was SET the all of registry i suggest that they are reset and clear interrupt in end of irq_handler like AIC_EIOC interrupt estatuse and etc that you can see in my code !!
Come on man, how about actually opening the user manual of your processor. Why are you so helpless? Work the problem!
"if i want reset the interrupt on exit from the irq_handler what work should I do ?"
That is really basic stuff - absolutely fundamental to any use of the interrupts!
Do you mean to say that you've been working on this for (over?) 2 months, and you haven't carefully studied that in the datasheet and/or "user manual" and any other documentation you can lay your hands on?!
And with all of this, how could you think it is a buge in the compiler?
NO! I read carefully the datasheet and all user manual about at91sam7x and usart and etc.
if you see my code you see that I do all thing's you say to me for reset interrupt and do that: "...any use of the interrupts!,..." but I have that bug yet...
my problem doesn't basically problem!!
because I search in all of internet and doesn't find any correct sample or example for usart interrupt!!
the all of them had bug and doesn't work correctly
dear tamir...are you think in 2 month what i do ?? I read all of the user manual and data sheet and all see all of the usart sample!!!
but I have that problem yet!!! I don't know why you think that this is a normal bug ?? whay realy??? are you work with usart interrupt hitherto?? realy you can run it witout any bug???
OK, so go right back to basics.
Write a really simple "Hello, world" program that just transmits characters using the UART and interrupts.
When you have that working, add interrupt-driven serial receive.
And so on, step by step...
ok.. thans Mr.neil I doesn't have any problem in send and receive data (without work with interrupt) ...the all of my problem is in interrupt mode .. my usart is realy correct..my RXRDY usart interrupt in basic step doesn't work correctly !!
i doesn't want a big thing from you !!! I only want a one realy basically sample!!only one that work without any bug!!!is in all of the word exist one correct program for it??? if yes pleas send me to rationalization!! but it not exist any correct sample for it what is meaning of that??
"..but iF not exist any correct sample for it what is meaning of that??"
So post the smallest, complete example that illustrates your problem.
Just a simple example that sends & receives characters using the UART and interrupts.
ok...my program is so simple example of it..this program must return any caractere of receive. it is very simple . thank you very much.
they are the links for download it:
http://www.keil.com/forum/docs/thread16626.asp#msg84658
OR
and one thing i should say about my program is that: i want my program send every bit that receive suddenly.
and since speed of it, i used usart interrupt to do it very quickly.
i want my program send every bit that receive suddenly.
You may have read the user manual, but you failed to understand it. Your UART will generate an RX interrupt after receiving a word of various sizes and possibly a variable amount of these words, but not after detecting a bit. Why would you want that in a UART?
Dear everybody I'm friend of Ali Salehi. I think you must know what we want to do with Micro controller. We want to write a program that send a receive byte from serial port (as like a serial(RS-232) hardware loopback). I know that if i want to do that i must use micro controller serial in interrupt mode. but, we have a problem with interrupt mode. also we wrote a program for timer and used the interrupt mode but did not work correctly too.so Please don't say anything like as "that is basic problem". If you work with ARM interrupts, Please Help us. I think it is necessary to say that we run LCD & ADC & IO in ARM and worked correctly.
It is simply hard to believe that two people, that are supposed to be skilled or at least have the capacity to learn new things, are stuck on this. You too don't read or try to understand what people are saying to you, as you don't really bother to read the user manual in detail or the samples. Nobody here is going to do your homework - face it.
Ho, by the way I caught you in a little lie - did you REALLY successfully enable LCD control without interrupts? I don't think so.
I guess controlling an LCD is possible without interrupts, but the result cannot be really satisfactory!
Sorry, but I don't trust those "file sharing" sites, I'm afraid.
You should be able to Post the source of a simple program into the forum.
Be sure to read the instructions on posting code first...
One thing to note: do not use TABs to lay-out your code - use only spaces.
Depends on the hardware. I'm using an LPC3250. The LCD controller is not using interrupts. Simply a case of setting up the hardware and letting it do it's own thing. It works a treat.
Not sure about the at91sam7x256 that Tweedle Dum and Tweedle Dee are using here, but it surprises me that they can get an LCD controller going, but struggle with a USART.
ok..if you really can't terust me..I wirte all of my program in end if this page!!!
"...also we wrote a program for timer and used the interrupt mode but did not work correctly too..."
So there's either another buge in the compiler or you need to do some serious reading up on interrupts and how to use them.
1- we really successfully enable lcd without interrupt and without work with serial !!!
we wrote handle serial for use LCD..in other language we only work with I/O for run LCD...
2_ I don't know why you think that we are lying???why we should lie to you??? only for one homework we 2 month tray to resolve it's problem?? i am sorry for ourself!!
this is our code:
#include <at91sam7x256.h> #include <lib_at91sam7x256.h> unsigned char test = 48; void Usart0IrqHandler(void); // function prototype for USART0 handler volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; // pointer to PMC data structure volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA; volatile AT91PS_USART pUsart0 = AT91C_BASE_US0; volatile AT91PS_AIC pAIC = AT91C_BASE_AIC; // pointer to AIC data structure volatile AT91PS_SYS pSYS=AT91C_BASE_SYS; int main(void){ test=70; pPIO->PIO_PDR = (AT91C_PA0_RXD0 | AT91C_PA1_TXD0); pPMC->PMC_PCER = (1<<AT91C_ID_US0); // enable usart0 peripheral clock pPIO->PIO_ASR = (AT91C_PIO_PA0 | AT91C_PIO_PA1); // define peripheral A select regidtry pPIO->PIO_BSR = 0; // define peripheral B select regidtry pUsart0->US_CR = (AT91C_US_RSTRX | // reset receiver AT91C_US_RSTTX | // reset transmitter AT91C_US_RXDIS | // disable receiver AT91C_US_TXDIS); // disable transmitter pUsart0->US_MR = (AT91C_US_PAR_NONE | // no parity 0x3 << 6); // 8-bit characters pUsart0->US_IER = 0x0000; // no usart0 interrupts enabled (no effect) pUsart0->US_IDR = 0xFFFF; // all usart0 interrupts disabled pUsart0->US_BRGR = 0x139; // CD = 0x139 (313 from above calculation) // FP=0 (not used) pUsart0->US_RTOR = 0; // receiver time-out (disabled) pUsart0->US_TTGR = 0; // transmitter timeguard (disabled) pUsart0->US_FIDI = 0; // FI over DI Ratio Value (disabled) pUsart0->US_IF = 0; // IrDA Filter value (disabled) pAIC->AIC_IDCR = (1<<AT91C_ID_US0); // Disable USART0 interrupt in AIC pAIC->AIC_SVR[AT91C_ID_US0] = (unsigned int)Usart0IrqHandler; // Set the USART0 IRQ handler address in AIC // Source Vector Register[6] pAIC->AIC_SMR[AT91C_ID_US0] =(AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 0x4 ); // Set the int source type and pri // in AIC Source Mode Register[6] pAIC->AIC_IECR = (1<<AT91C_ID_US0); // Enable the USART0 interrupt in AIC // enable the USART0 receiver and transmitter pUsart0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN; // enable the USART0 receive interrupt pUsart0->US_IER = AT91C_US_RXRDY; // enable RXRDY usart0 receive interrupt pUsart0->US_IDR = ~AT91C_US_RXRDY; // disable all other interrupts except RXRDY test=70; do{ }while(1); } void Usart0IrqHandler(void){ int statuse; statuse= pUsart0->US_CSR; test=pUsart0->US_RHR; pUsart0->US_THR=test; if (AT91F_US_TxReady(AT91C_BASE_US0)==0) do{ }while(AT91F_US_TxReady(AT91C_BASE_US0)==1); AT91C_BASE_AIC->AIC_EOICR = 0; return ; }
View all questions in Keil forum