CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

help about PIC16F18877

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

help about PIC16F18877
PostPosted: Fri Dec 23, 2016 7:04 am     Reply with quote

hi,
I am trying to work with PIC16F18877 in MPLAB 3.5 + CCS 5.066 + Pickit3
but I cant make anything ...
I'm not able to work with the simulator.
I'm not able to work with the debug.
I'm not able to work with read a simple data eeprom in PIC
if you help me i appreciate very much.

Simple code:
Code:

#include <.\drivers\16F18877.h>

//#Fuses NOEXTOSC
#Fuses RSTOSC_HFINTRC
//#Fuses RSTOSC_HFINTRC_PLL
//#Fuses RSTOSC_SOSC
//#fuses ECH
#Fuses NOCLKOUT
#Fuses NOCKS
#Fuses NOFCMEN
#Fuses NOMCLR
#Fuses NOPUT
#Fuses NOLPBOR
#Fuses NOBROWNOUT
#Fuses NOZCDDIS
#Fuses NOPPS1WAY
#Fuses NOSTVREN

#Fuses DEBUG

#Fuses NOWDT
#Fuses NOWRT
#Fuses NOSCANE
#Fuses NOLVP

#Fuses NOPROTECT
#Fuses NOCPD

//#use fast_io(a)
//#use delay(clock=4000000)//,RESTART_WDT)
#use delay(internal=4MHz)

#DEFINE sTRISA   0x0C

#byte PORTA             = 0x00C
#bit  IO_CLK_NIV_1   = PORTA.0

void main(void){
    set_tris_a(sTRISA);
    while(TRUE){
        IO_CLK_NIV_1 =1;
        IO_CLK_NIV_1 =0;
    }   
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 23, 2016 9:22 am     Reply with quote

Your first program is too complicated. Try a very simple LED blinking
program, as shown below. I don't have a 16F18877 to test in hardware
but I've looked at the .LST file for this program and it seems like it should
work. I used CCS compiler version 5.066 for this. What is your version ?
Code:
#include <16F18877.h>
#fuses NOMCLR, NOWDT
#use delay(internal=4M)

//================================
void main(void)
{

// Blink an LED once per second.
while(TRUE)
  {
   output_high(PIN_A0);
   delay_ms(500);
   output_low(PIN_A0);
   delay_ms(500);
 }   

}



Here is a schematic of the Pin A0 circuit. I don't know if you are running
the 16F18877 at 3.3v or 5v, so I put in a resistor value that will work with
either one.
Code:

pin      220 ohms      LED       
A0  -----/\/\/\/------->|----
                            |
                            |
                          -----  Ground 
                           ---
                            -
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Dec 23, 2016 9:59 am     Reply with quote

First, try with the CCS instructions.
Just do an output_toggle(PIN_A0);
Something like:
Code:

#include <16F18877.h>

#Fuses NOMCLR
#Fuses NOPUT
#Fuses NOBROWNOUT
#Fuses ZCDDIS
#Fuses NOPPS1WAY
#Fuses STVREN
#Fuses NOWDT
#Fuses NOWRT
#Fuses NOSCANE
#Fuses NOLVP
#Fuses NOPROTECT
#Fuses NOCPD

#use fast_io(a)
#use delay(internal=4MHz)

void main(void)
{
    set_tris_a(0b11111110); //using fast_io, so set pin A0 as output
    while(TRUE)
    {
        output_toggle(PIN_A0);
    }   
}


Get rid of the DEBUG fuse. MPLAB will enable this itself if you build in debug mode.
Unless you are using the zero crossing detector, you want ZCDDIS.
Also you should always run with STVREN, unless you add code to check for a stack overflow.
Generally for output, you should always output to the LAT register, not the port. You only output to the port, on chips where the LAT is not available (most PIC16's...).
Either control the clock completely yourself, or let the compiler control it. Currently you have 'half and half'.
Honestly new chips often have oddities for a few data sheet and compiler versions.

Something very strange, since this reports 100% RAM usage...
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sat Dec 24, 2016 7:00 am     Reply with quote

thank you very much,
I tried to use simulator with this above code but it stop when I press F7,

E0108-SIM: Failed simulator operation: {0} com.microchip.mplab.mdbcore.simulator.SimulatorException: E0101-SIM: Failed to disassemble instruction Invalid Instruction
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sat Dec 24, 2016 7:02 am     Reply with quote

I think I am going to another PIC, more old, like your sugest.
Do you have anythink bad about PIC16F917 ?
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 24, 2016 9:27 am     Reply with quote

PIC selection should be based on what YOU need it to do. If it's a single project, then find one that does just that.
In my case I use the 18F46K22 for 99% of products and projects. While it has LOTS more memory and periphersals than needed, over the years I cut a lot of code for my 'library'. As well one PCB does most projects and I haven't run out of pins, yet....

As a 'baseline' PIC, choose one with a hardware UART and lots of memory. An internal clock source is nice (frees up 2 pins).
Also ones like the 46k22 will run at 3 volts or 5, something to consider when interfacing to external devices like GPSes, etc.

Jay
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Sat Dec 24, 2016 1:48 pm     Reply with quote

I need to work with PIC16f and 40 I/Os.....I already changed the project to the PIC16F917.
Very thank you for all
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Dec 24, 2016 3:37 pm     Reply with quote

The one you were trying to use is a very new PIC. In fact on the MicroChip site for the last couple of days it has been giving the data sheet as 'unavailable', suggesting a revision may be coming.
The compiler is definitely having some issues with it, but this is normal when chips first come out. Being a 'early adopter' is really not recommended unless you need a feature on a new PIC.

Anyway the more normal chip should solve the problems.

Have a good Christmas everyone. Smile
greg.jones



Joined: 28 Mar 2017
Posts: 2

View user's profile Send private message

Re: help about PIC16F18877
PostPosted: Tue Mar 28, 2017 11:41 am     Reply with quote

sergioigel wrote:
hi,
I am trying to work with PIC16F18877 in MPLAB 3.5 + CCS 5.066 + Pickit3
but I cant make anything ...
I'm not able to work with the simulator.
I'm not able to work with the debug.
I'm not able to work with read a simple data eeprom in PIC
if you help me i appreciate very much.

Simple code:
Code:

#include <.\drivers\16F18877.h>

//#Fuses NOEXTOSC
#Fuses RSTOSC_HFINTRC
//#Fuses RSTOSC_HFINTRC_PLL
//#Fuses RSTOSC_SOSC
//#fuses ECH
#Fuses NOCLKOUT
#Fuses NOCKS
#Fuses NOFCMEN
#Fuses NOMCLR
#Fuses NOPUT
#Fuses NOLPBOR
#Fuses NOBROWNOUT
#Fuses NOZCDDIS
#Fuses NOPPS1WAY
#Fuses NOSTVREN

#Fuses DEBUG

#Fuses NOWDT
#Fuses NOWRT
#Fuses NOSCANE
#Fuses NOLVP

#Fuses NOPROTECT
#Fuses NOCPD

//#use fast_io(a)
//#use delay(clock=4000000)//,RESTART_WDT)
#use delay(internal=4MHz)

#DEFINE sTRISA   0x0C

#byte PORTA             = 0x00C
#bit  IO_CLK_NIV_1   = PORTA.0

void main(void){
    set_tris_a(sTRISA);
    while(TRUE){
        IO_CLK_NIV_1 =1;
        IO_CLK_NIV_1 =0;
    }   
}




Hello,

Do you happen to have the CCS device driver for the PIC1618877 ? I have one of these lying around and want to test this for my project using the CCS compiler but I cannot find the driver anywhere. It's not under my devices folder either. Will appreciate if you could help me out.

Thanks



Thanks!
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Tue Mar 28, 2017 1:58 pm     Reply with quote

No one here can give that to you legally. You'll need to either purchase a more up to date compiler, or contact CCS support and see if they can get you one.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Mar 28, 2017 2:17 pm     Reply with quote

It's also impossible.

There is no such thing as a 'device driver'' for a chip. The header file, does not add support to the compiler for a chip. It uses the internal functions that are actually in the core compiler database. So a header file on it's own won't allow you to compile for a chip. You need a compiler that supports it....
greg.jones



Joined: 28 Mar 2017
Posts: 2

View user's profile Send private message

PostPosted: Tue Mar 28, 2017 3:49 pm     Reply with quote

Thanks for the information. I had no idea since I'm new to microcontroller.
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

Re: help about PIC16F18877
PostPosted: Sat Mar 03, 2018 11:25 am     Reply with quote

Excuse me, I forgot to give a return...
I had to update the compiler for this PIC twice.
CCS gave me support and identified bugs.
After some successful hits and codes, everything worked.
Thank you very much for the existence of this forum.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group