PDA

View Full Version : how to program 18f4550 to print receipt



suzun
8th October 2009, 16:50
Hi
I am very new to microcontroller programming and I am now doing some project to print receipt from pic18f4550. I use rs232 and Set the oscillator speed to 48MHz (using a 20MHz crystal).I am communicating with the PIC at a serial speed of 19200. For my configuration bit setting, I set the "PLL Pre Scaler" in this case, with a 20Mhz Crystal, I am using divide by 5, which results in a signal at 4Mhz.
I set the System Clock PostScaler, in this case it is set to divide by 2.
then set the USB Clock, in this case 96Mhz / 2
then set the oscillator in this case HSPLL .

The following is my program and I am not able to get the correct output form the printer. Is there anything wrong with my program ?

#include <p18f4550.h>
//#include"rs232.h"
#include<stdio.h>
#include <delays.h>
#include <math.h>
#include <usart.h>

//------------------------------------------------------------
#define USART_BAUD_115K2 8


void main()
{ int i =0;
char inputBuffer=0;
ADCON1 = 0x0F;
CMCON = 0x07;
TRISCbits.TRISC6=0; // Tx
TRISCbits.TRISC7=1; //Rx
baudUSART(BAUD_IDLE_RX_PIN_STATE_HIGH &
BAUD_IDLE_TX_PIN_STATE_HIGH &
BAUD_8_BIT_RATE &
BAUD_WAKEUP_ON &
BAUD_AUTO_OFF);

OpenUSART( USART_TX_INT_OFF
& USART_RX_INT_OFF
& USART_ASYNCH_MODE
& USART_EIGHT_BIT
& USART_CONT_RX
& USART_BRGH_HIGH,156); // buad= 4MHz/(16*(1+19200))


while(i<=10)
{
putrsUSART("suzunmon ");
i=i+1;
}


CloseUSART();
while(1);

}

hope to get reply soon :) thanks
SUZUN

chuckieboy
8th October 2009, 19:33
The only thing that I can see is that is not Proton it looks like C to me, here we use basic