??? 03/07/07 05:28 Read: times |
#134441 - More info Responding to: ???'s previous message |
Eugene, you need to do a bit of reading and break the problem down into small parts (others have mentioned this). As for accessing the internal SFRs (special function registers) in 'c', the compiler normally has an include file that describes these. Thus in 'c', it is similar to assembler like: #include <8051.h> //different compilers have different names SBUF = ' A'; Depending on your compiler and configuration, sending a string of characters should be as easy as: printf("ATI\r\n"); but printf is a large piece of code. So to break down your tasks: 1/ implement the full RS232 interface. Port pins are used for the control signals. 2/ initialise the uart 3/ have functions to read write characters to the uart. You will probably have to use 'circular buffers' on the receive side along with interrupts so that no characters are missed. 4/ Write code to send the appropriate commands to the modem and respond to the RS232 interface as required. This is a large job in itself - lots of reading and fiddling involved. Once you've got this far, having it dial, answer etc show be fairly easy. One thing you need to remember is that the modem does not respond immediately - they can take a little time (100's mS) so you need to incorporate some timing functions that allow you to time events. This could be as simple as a delay() function or more sophisticated. I would suggest you connect the modem to your PC and use Hperterminal (or terminal program of choice) to manually operate the modem. This way you can send commands manually and see how the modem responds. |