Hi I am using 89C51ED2 for my projects.From SPI I am receiving datas from peripherial.I using inbuilt registers like SPDAT,SPCON.But I can't call my SPI function from interrupt service routine My CODE is void readspi(void){ Enablecs(); SPDAT = addr; while((SPSTA & 0x80) == 0); spivalue = SPDAT; while((SPSTA & 0x80) == 0); Disablecs(); } void Ext0_ISR(void) interrupt 0 using 1{ readspi(); } void main(void){ static unsigned int spivalue; while(1){ } } Please help me to over come this problem
codearchitect for Philips LPC932 free from http://www.esacademy.com generates code for many peripherals. Usually this code can, with minuscule changes, be used on the 89x51xx2 series. Erik PS if you use these processors or the sane SILabs derivatives - or even some others, have a look at the CodeArchitect even if you are not Manoj.
"I can't call my SPI function from interrupt service routine" Why not? Please explain precisely! BTW: Note that you ISR uses Register Bank 1; your readspi() function would need to use the same bank... Is readspi() also calle from non-interrupt code? If not, why make it a separate function? Note that having wait loops in an ISR (or called from an ISR) is generally not a Good Thing. Note also that having wait loops with no timeout or other "emergency escape" mechanism are definitely not a Good Thing - sooner or later, your code will hang in one of them!
Neil I am using Non interrupt SPI function only.But my application is like that My peripheral give a one second interrupt that time only I have to read data.So in this condition my code does n't works(I think it lockup in while loop)Please give me some good suggestion.
I am using Non interrupt SPI function only. That, most likely is your problem. SPI is REAL time NOT the friggin "real enough" but REAL. Non-interrupt SPI is likely not to be timely, even when presumed to be real enough" That interrupt code is more difficult than non-interrupt code is nothing but an urban legend Again, if you grab CodeArchitect, you will be amazed. Erik
Hi "Again, if you grab CodeArchitect, you will be amazed" I cann't get that code .Please help me to find it out.
I posted codearchitect for Philips LPC932 free from http://www.esacademy.com what is your problem "I can not get that code"? Erik
Hi Thanks a lot!I got code from http://www.esacademy.com and I solved my problem also.........