Hi Guys, i'm banging my head against a brick wall at the moment, if anyone can take a quick look over the code, it would be most appreciated.
I'm using the PIC18f4580 and trying to simply transmit rs232 to my computer via hyperterminal using the max233. When i compile the code on my 16f877a it works fine (ob altering the SPBRG setting), but on the 18f, i have no luck.
Here is my code:
I am running the pic at 8mhz using the internal osc (i hope) although don't have any available scope to check this.
Any help would be greatly appreciated
Cheers
Richb
I'm using the PIC18f4580 and trying to simply transmit rs232 to my computer via hyperterminal using the max233. When i compile the code on my 16f877a it works fine (ob altering the SPBRG setting), but on the 18f, i have no luck.
Here is my code:
Code:
#include <pic18f4580.h>
void putch(unsigned char c)
{
while(!TXIF) continue; // set when register is empty
TXREG = c;
}
void puts(const char *str)
{
while(*str){
putch(*str);
str++;
}
}
void rs232_init() // Sets USART to 9600 Baud, 8-bit data
{
SPBRG = 51;
BRGH = 1;
BRG16 = 0; //
SYNC = 0; // Asynch Operation
SPEN = 1; // Enable Serial Port
CREN = 1; // Enable Reception
TXEN = 1; // Enable transmission & Set TXIF
TX9 = 0; // 8- or 9-bit transmission
RX9 = 0; // 8- or 9-bit reception
RCIE = 1;
}
void main(void)
{
IRCF2 = 1;
IRCF1 = 1;
IRCF0 = 1;
/*disable comparator module*/
CM0 = 1;
CM1 = 1;
CM2 = 1;
/*Disable PSP (parallel slave port) */
PSPMODE = 0;
PCFG3 = 1;
PCFG2 = 1;
PCFG1 = 1;
PCFG0 = 1;
LATD = 0xFF;
LATE = 0x00;
TRISD = 0x00;
TRISA = 0xFF;
TRISE = 0x00;
TRISC6 = 0;
TRISC7 = 1;
rs232_init();
puts("move forward!!");
}
I am running the pic at 8mhz using the internal osc (i hope) although don't have any available scope to check this.
Any help would be greatly appreciated
Cheers
Richb