View previous topic :: View next topic |
Author |
Message |
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
help about PIC16F18877 |
Posted: Fri Dec 23, 2016 7:04 am |
|
|
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;
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 23, 2016 9:22 am |
|
|
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
---
- |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Fri Dec 23, 2016 9:59 am |
|
|
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... |
|
![](templates/subSilver/images/spacer.gif) |
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
|
Posted: Sat Dec 24, 2016 7:00 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
|
Posted: Sat Dec 24, 2016 7:02 am |
|
|
I think I am going to another PIC, more old, like your sugest.
Do you have anythink bad about PIC16F917 ? |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Sat Dec 24, 2016 9:27 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
|
Posted: Sat Dec 24, 2016 1:48 pm |
|
|
I need to work with PIC16f and 40 I/Os.....I already changed the project to the PIC16F917.
Very thank you for all |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Sat Dec 24, 2016 3:37 pm |
|
|
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](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
greg.jones
Joined: 28 Mar 2017 Posts: 2
|
Re: help about PIC16F18877 |
Posted: Tue Mar 28, 2017 11:41 am |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
jeremiah
Joined: 20 Jul 2010 Posts: 1329
|
|
Posted: Tue Mar 28, 2017 1:58 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Tue Mar 28, 2017 2:17 pm |
|
|
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.... |
|
![](templates/subSilver/images/spacer.gif) |
greg.jones
Joined: 28 Mar 2017 Posts: 2
|
|
Posted: Tue Mar 28, 2017 3:49 pm |
|
|
Thanks for the information. I had no idea since I'm new to microcontroller. |
|
![](templates/subSilver/images/spacer.gif) |
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
Re: help about PIC16F18877 |
Posted: Sat Mar 03, 2018 11:25 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|