sanket.joshi
Member level 3
- Joined
- Jun 27, 2013
- Messages
- 65
- Helped
- 8
- Reputation
- 16
- Reaction score
- 8
- Trophy points
- 8
- Location
- Mumbai,India
- Activity points
- 386
void timer_set( ) // Sets the timer to 3 times the baud rate.
{
[COLOR="#FF0000"]T2CON[/COLOR] = 0x04; // Load Timer 2 control register
[COLOR="#FF0000"]TH2[/COLOR] = 0xFF; // Load Timer 2 high byte
[COLOR="#FF0000"]RCAP2H[/COLOR] = 0xFF; // Load Timer 2 reload capt. reg. high byte
[COLOR="#FF0000"]TL2[/COLOR] = 0xE0; // Load Timer 2 low byte
[COLOR="#FF0000"]RCAP2L[/COLOR] = 0xE0; // Load Timer 2 reload capt. reg. low byte
//Disable Interrupt Service Routine
//ET2 = 0;
//TR2 = 0;
}
I began to work on your code, when I soon realized you could not have successfully compiled it for the AT89C51.
To begin with the AT89C51 only has two timers, Timer0 and Timer1, and yet you have attempted to utilized a third timer, Timer2, which doesn't exist in an AT89C51.
Code:void timer_set( ) // Sets the timer to 3 times the baud rate. { [COLOR="#FF0000"]T2CON[/COLOR] = 0x04; // Load Timer 2 control register [COLOR="#FF0000"]TH2[/COLOR] = 0xFF; // Load Timer 2 high byte [COLOR="#FF0000"]RCAP2H[/COLOR] = 0xFF; // Load Timer 2 reload capt. reg. high byte [COLOR="#FF0000"]TL2[/COLOR] = 0xE0; // Load Timer 2 low byte [COLOR="#FF0000"]RCAP2L[/COLOR] = 0xE0; // Load Timer 2 reload capt. reg. low byte //Disable Interrupt Service Routine //ET2 = 0; //TR2 = 0; }
There are numerous other issues as well.
I do not mind assisting you, however I am not going to write the entire set of softUART routines.
You must at least show some effort and when you hit a snag, ask and I will assist.
BigDog
I m doing one project in which i want to interface GSM Module and RF-ID Reader to 89C51..
but problem is there is only one UART for 89C51..
I do not have an AT89C51 available....
To receive data serially using UART or Soft UART you should use interrupts. Dta can come at any time so uC should be able to capture data at any time. If interrupts is not used data capture will not be successful.
There are so many many methods to solve a same problem, but it matters which way you are going... The Ext interrupt will respond very faster no doubt It takes about two three machine cycles.. you need not use ext interrupt for soft uart... the timer interrupt only sufficient that has to tick for every bit in your baud rate after enabling the receiver section.... if you receive a low bit in the input start storing the upcoming bits for 8 locations and make it Idle... Use the same timer isr for transmit once your baud-rate perfectly matched with host then there will be no more problems.....
Where do you stuck in? configuring values?? or isr logic??
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?