Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

CCS C Help!!!

Status
Not open for further replies.

Wilksey

Member
Hi guys,

I have compiled a program in HITECH C which uses a software bit banged serial routine on a 16F887. All works fine, same board, same level shifts etc, but this time I created a simple program using CCS C V4.105 and the serial message is coming out with parity errors and incorrect data. Any help appreciated.
4MHZ internal clock btw.

Code below.
main.c
Code:
void main()
{
   setup_oscillator(OSC_4MHZ);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_ccp1(CCP_OFF);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(GLOBAL);

   while(1)
   {
      printf("1234");
      delay_ms(1000);
   }

}
main.h
Code:
#include <16F887.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                   
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES RESERVED                 //Used to set the reserved FUSE bits

#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_A0,rcv=PIN_A1)
 
Ok, fixed it by putting this line below
Code:
enable_interrupts(GLOBAL);
:
Code:
set_tris_a(0b01000000);
Ooops!

Problem now is it is riddled with parity errors, i have changed the use code to:
Code:
#use rs232(baud=9600,xmit=PIN_A0,rcv=PIN_A1, parity=N,stream=pc)

Still doesn't want to play!

Any ideas?
 
Status
Not open for further replies.

Latest threads

Back
Top