Problém s nastavením USARTu pro 18F1220
talanda.moje2@seznam.cz
talanda.moje2@seznam.cz
Pondělí Květen 19 21:54:42 CEST 2008
Hezký den,
Vyrábím si sledovací systém ve kterém mimo jiné komunikuje mikrokontroler s mobilním telefonem a pořád nejsem schopný tu komunikaci nastavit. Nemoh by jste m někdo poradit, kde je v tom kódu chyba?
op. systém: XP
PIC: 18f1220
telefon: siemens C35
Compiler: C18 C-language compiler použitý v MPLAB
programer: ICD2
interní oscilátor a automatický reset
#pragma config OSC=INTIO2
#pragma config PWRT=ON
#pragma config BOR=ON
#pragma config BORV=42
#pragma config WDT=OFF
#pragma config LVP=OFF
#include <p18f1220.h>
#include <string.h>
#include <delays.h>
#include <portb.h>
#include <usart.h>
void main (void)
{
char usartTX2[]="ATD737635740;";
OSCCONbits.IRCF2 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF0 = 1;
OSCCONbits.SCS1 = 0;
OSCCONbits.SCS0 = 0;
//The next 5 initializations are set according to the PIC datasheet
//requirements for USART recieve/trans
TRISBbits.TRISB1 = 1; //TX set to output
TRISBbits.TRISB4 = 1; //RX set to 1, but will be set to 0 by PIC for input(as specified in datasheet)
ADCON1bits.PCFG6 = 1; //not sure what these next two are, but setting as specified in datasheet
ADCON1bits.PCFG5 = 1;
RCSTAbits.SPEN = 1; //setting serial port enabled
TXSTAbits.SYNC = 0; //asynchronous mode
// PIE1.TXIE = 0;
BAUDCTLbits.BRG16 = 0; //8 bit transfer
TXSTAbits.BRGH = 1; //BRGH high
TXSTAbits.TXEN = 1; //enable transmit
/*
* Open the USART configured as
* 8N1, 192000 baud, in polled mode
*/
OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 25); //[8000000/(19200*16)] - 1 = 25
SPBRG= 25;
putsUSART(usartTX2);
}
Další informace o konferenci Hw-list