my problem is i am trying to send data through hyper terminal to pic i m using USART
when i try to send character 'a' through hyper terminal it receives 0xB1 in hex i didnt get it what is the problem.
help me out
check the max232 IC circuit and the capacitor used.....also as wp100 mentioned .... First of all you need to try to bring up the board with LED toggelling ...then use interrupt timer... Many times I had faced the problem with configuration register setting in PIC18F family play a critical role.....Also I will recommend you check your external oscillator too in case your are using it.... Also please put your schematic and code on the forum so may people can able to help you out with this problem
tnx guys
actually the problem in usart configuration,
but now im enabling the rx interrupt and receive packet of data for that i have to wait (DataReady) function used but while i m using that function i didnt get Timer1 interrupt it stuck in wait and if i dont used wait function i didnt get whole data only first byte received.
I use MODSCAN for communication which send 8 byte of packet
Is there any method to get whole 8byte packet without waiting?
.......
#pragma interrupt chk_isr void chk_isr(void){if(INTCONbits.TMR0IF==1)// Timer0 causes interrupt.....?{
T0_ISR();// yes then execute Timer0 programe.}if(PIR1bits.TMR1IF==1){
T1_ISR();}if(PIR1bits.RCIF==1){
RX_ISR();}}#pragma code HI_PRIO_INT=0x0008 // high priority interrupt location.void HI_PRIO_INT(void){
_asm
goto chk_isr
_endasm
}void T0_ISR(void){
TMR0H =0xB1;
TMR0L =0xDF;
INTCONbits.TMR0IF=0;}void T1_ISR(){
rx_timeout =0;
TMR1H =0xFC;
TMR1L =0xBD;
PIR1bits.TMR1IF=0;}void RX_ISR(void){unsignedchar data;
buffer = rec_buf;
rx_timeout=1;
T1CONbits.TMR1ON=1;if((qip==0)&&(rx_state==RXTX_IDLE)){
qip=1;do{while(!DataRdyUSART());// Wait for data to be received
data =getcUSART();// Get a character from the USART*buffer = data;// and save in the string
buffer++;// Increment the string pointer
rx_state +=1;}while(rx_timeout==1);}
qip=0;
T1CONbits.TMR1ON=0;
PIR1bits.RCIF=0;}
You need to understand bit more on the ISR .....and high_isr() and low_isr() function....
First of all you need to know that interrupt service rountine is never be the part of the main() function....it will never called in the main()....it is separate free running entity most of time based on the configuration of interrupt in main() function and equivalent event happen at run time ( mostly non-predictable activity)....Now let consider an example timer overflow interrupt and receive character interrupt can come at a time in system but ....your priority of interrupt will tell which one to serve first..... so that you have two mode one is high priority and second one is with low priority ISR.... So first understand and finalize the interrupt that you are planning to use ....then assign the priority of them....
the way that you are written the functions as and interrupt are appears to be fine but....I think you need to think a bit and then write the ISR low or high ISR.....
thanks to all guys
I m done with my project the problem was i am used 3 interrupt
timer0, timer1, receiver in which i configured t1,rx as high priority
i entertained t1 and rx but as t0 is in low interrupt vector address it never
go to that routine bcoz of this im stuck in higher isr.
there is one more question
if i used t0 as low priority and t1 and rx as high priority
is that necessary to write code for t0 like
.
.
.
void high_isr()
{
if(t0==1)
t0_isr();
if(rx==1)
rx_isr();
if (t1==1)
t1_isr();
}
above code is just a pseudo code
when i used t0 in another function it never go to that routine
the way that you are written is ok but that will not handle priority....
Try the code some thing like this....
Code:
void high_isr()
{
if((t0==1)&&(rx==1)&&(t1==1)) // t1 is highest priority
{
t1_isr();
}
if((t0==1)&&(rx==1)&&(t1==0)) // rx has higher priority than t0
{
rx_isr();
}
followed with the cases that you have .........
}
I hope this will give you an idea based on your system ....