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 4.120 + pic18f26k22 uart

Status
Not open for further replies.

Wilksey

Member
Hi Guys,

I have just upgraded to CCS C 4.120 to enable programming of the PIC18F26K22, I have created a quick test program to run the UART using the wizard, and I cant seem to get it to simulate properly in Proteus, it says logic contention on net in the warnings in Proteus.

I want to test this before putting it onto the chip, and I have had this issue before and it's because the pins are multiplexed, i'm thinking i've missed something.

Anyways.

Test code (mian.c)
Code:
#include <main.h>


void main()
{

   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
   setup_oscillator(OSC_4MHZ|OSC_INTRC|OSC_31250|OSC_PLL_OFF);
   while(1)
   {
   }
}

test code (main.h)
Code:
#include <18F26K22.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPLLEN                  //4X HW PLL disabled, 4X PLL enabled in software
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOSTVREN                 //Stack full/underflow will not cause reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(int=4000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)

I also created another project and turned things off specifically, and it still does the same.
(main.h)
Code:
#include <18F26K22.h>

#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES NOPLLEN                  //PLL Enable
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOBROWNOUT               //No brownout reset
#FUSES WDT_NOSLEEP              //Watch Dog Timer, disabled during SLEEP
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#fuses NODEBUG

#use delay(int=4000000)
//#use delay(int=64000000)
#use rs232(baud=38400,parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8,stream=ILIGHT_PC)
#use rs232(baud=38400,parity=N, xmit=PIN_B6, rcv=PIN_B7, bits=8,stream=ILIGHT_TFU)

and the C file (main.c)
Code:
#include <main.h>

void main()
{
   setup_timer_0(T0_OFF);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_ccp1(CCP_OFF);
   setup_ccp2(CCP_OFF);
   setup_ccp3(CCP_OFF);
   setup_ccp4(CCP_OFF);
   setup_ccp5(CCP_OFF);
   setup_dac(DAC_OFF);
   setup_adc(ADC_OFF | NO_ANALOGS);
   setup_oscillator(OSC_4MHZ|OSC_INTRC|OSC_PLL_OFF);
   while(1)
   {
  
   }
}

I have tried setting TRIS but doesn't make a difference!

I used to really like CCS C, and only upgraded from 4.105 for the newer chips, but it seems that the newer chips are having issues with the compiler, which is a shame! I compiled some code for another PIC chip, cant remember the exact variant now, but I used C18 and it worked perfectly, tried to compile the same thing in CCS C and I have a similar issue! Still never resolved it.

Any help appreciated!

Wilksey
 
Turns out, according to the CCS forums that CCS C isn't compatible with Proteus!
Whether it is just that particular chip and that particular version of the compiler, who knows?! C18 code worked fine, but several CCS compiled codes did not. Strange!

So a word of warning to anyone else experiencing similar issues, it may be worthless trying for hours to get your CCS code to work with Proteus!!

Wilksey
 
i was under the impression proteus would run any cof file?? looks like proteus missed a trick by not being compatiable with CCS!! i like proteus but has some funny quirks
 
Yeah, well, according to the guys over in the CCS forum it isn't completely compatible, so who knows, I loaded the HEX file not the COF, but they are the same thing effectively as far as I know?

Wilksey
 
i tried a couple of CCS coff and hex files in proteus and 4 out of 5 wouldnt run!! shame seeing as CCS is so popular.
 
It is a shame as CCS is quite a simple to use compiler, and I dont always have the hardware, and it takes a few days to get the stuff from places like RS, Farnell, Digikey, etc, and then a day or two to build the hardware, so you're a week in before you can even start to code!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top