 |
 |
| View previous topic :: View next topic |
| Author |
Message |
viki2000
Joined: 08 May 2013 Posts: 233
|
|
Posted: Fri May 31, 2013 11:27 am |
|
|
There is no problem with the hardware...the ASM code on the same hardware works fine.
And I connected it as was suggested above.
I guess, next week, a recorded screen in debug mode with MPLAB and HITECH, XC8 compiler and SFR will clarify more things. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20161
|
|
Posted: Fri May 31, 2013 12:15 pm |
|
|
| On 'PORTA', the pins not set as outputs, will reflect the actual voltage on the pins. Hence the floating un-driven pins will give effectively random results. |
|
 |
viki2000
Joined: 08 May 2013 Posts: 233
|
|
 |
stinky
Joined: 05 Mar 2012 Posts: 99 Location: Central Illinois
|
|
Posted: Fri May 31, 2013 1:02 pm |
|
|
I tried your original code:
| Code: | #include <10F320.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_SW //No Watch Dog Timer, enabled in Software
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOLPBOR //Low-Power Brownout reset is disabled
#use delay(int=8000000)
#define LED PIN_A2
#define DELAY 1000
void main ()
{
//Example blinking LED program
while (true)
{
output_low(LED);
delay_ms(DELAY);
output_high(LED);
delay_ms(DELAY);
}
} |
Compiled and Burned on to a 10F320. The LED connected to PIN_A2 flashes as expected. CCS PCM C Compiler, Version 4.141. The only difference I see between what I compiled and what you posted is that I did not use an external header file to set fuses and constant definitions. I don't have any suggestions to offer. |
|
 |
viki2000
Joined: 08 May 2013 Posts: 233
|
|
Posted: Fri May 31, 2013 1:33 pm |
|
|
These are good news.
What kind of IDE enviroment did you use and what kind of programmer?
Did you use only CCS IDE environment with CCS suggested compiler as ICD-U64?
Or did you try also MPLAB or MPLABX with its CCS plugin and PICKIT programmer?
I checked the ini files for HITECH and also for XC8 compilers, the section for PIC10F320 and I found wrong mentioned
RAMBANK=40-7F as in datasheet (wrong)
instead of
RAMBANK=60-7F right values.
How is that with CCS compiler?
Are any ini files for PIC10F320? If yes then where?
I expect that in CCS IDE everything to be fine, but in MPLAB+CCS plugin to have a reference to RAMBANK=40-7F
What do you think?
Next week, hopefully, when I will receive the ICD-U64 programmer I will use only CCS IDE environment and I will test your code too and I will post a feedback.
Another idea will be to compile your code in CCS and with hex file obtained to create a MPLABX project which will be re-compiled in MPLABX with CCS plugin and finally burned in PIC10F320 with Pickit3. |
|
 |
stinky
Joined: 05 Mar 2012 Posts: 99 Location: Central Illinois
|
|
Posted: Fri May 31, 2013 1:48 pm |
|
|
I only use the command line interface to run the CCS compiler.
I used a PICkit2 and its software counterpart from microchip |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 31, 2013 2:21 pm |
|
|
I used the same program that Stinky used, except I have a 10F322
instead of a 10F320, so I changed the include file to 10F322.h, and
it worked. It's blinking the LED on pin RA2, 1 second on, 1 second off.
I tested this with vs. 4.140 and 4.141 and it works with both versions.
It also means the Option register issue doesn't apply to this series of PICs.
I checked the .LST file and the compiler doesn't write to the Option reg. |
|
 |
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Fri May 31, 2013 3:27 pm |
|
|
I saw this post and because I have a 10F322 on the shelf I thought, sure, I can make the LED blink - I do it all the time! That's just PIC programming 101. Lo and behold, I failed. Here is my code: | Code: | // 322Blink.c
//
// 8-pin DIP version - Connections:
//
// 1 - NC
// 2 - +5V
// 3 - RA2 -> 470R -> LED -> GND (Polarity of LED has been checked!)
// 4 - ICSP CLK
// 5 - ICSP DAT
// 6 - NC
// 7 - GND
// 8 - ~MCLR to ICSP
#include <10f322.h>
#fuses NOWDT //No Watch Dog Timer
#fuses INTRC
#fuses NOMCLR //Master Clear pin used for I/O
#fuses NOPUT
#use delay(clock=4M)
#define LED1 PIN_A2
void main()
{
// CCS sets PORTA to digital by default
// see LST file right after main()
while (TRUE) {
output_high(LED1);
delay_ms(500);
output_low(LED1);
delay_ms(500);
}
} |
I'm using a PicKit2 for programming, CCS version 4.135. Programming and reading back work fine. I looked at the assembler listing and it compares favorably to samples on the Microchip forum that claim they are working. I didn't see anyone setting any special registers, setting up timers or anything like that. So, why doesn't this work?
If anyone gets this working please let us know. _________________ Jürgen
www.jgscraft.com |
|
 |
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Fri May 31, 2013 3:41 pm |
|
|
Oops - overlapping posts.
I tried to compile Stinky's code and got an error on . It seems non-critical and took it out. Compiled. Still no-go. Could my version 4.135 be the problem? _________________ Jürgen
www.jgscraft.com |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 31, 2013 3:43 pm |
|
|
I installed vs. 4.135 and used your program and it works. The LED blinks
at a 1 Hz rate on a 10F322. My advice is to check your hardware
connections to the PIC. |
|
 |
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Fri May 31, 2013 4:44 pm |
|
|
Oops - victim of unmentionably stupid mistake. Works great. Thanks for checking the compiler version. _________________ Jürgen
www.jgscraft.com |
|
 |
viki2000
Joined: 08 May 2013 Posts: 233
|
|
Posted: Sat Jun 01, 2013 12:33 am |
|
|
Sorry if I did not understand right and clear up to now:
- did anybody tried to compile and burn the working codes above inside to MPLAB? |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20161
|
|
Posted: Sat Jun 01, 2013 2:22 am |
|
|
Key thing you have to do to work in MPLAB, is to set it to compile in 'release' mode.
By default, many versions wake up set to debug mode.
MPLAB itself does not actually do anything to the compile. The actual compiler is still CCS. However if the default setting is made, it overrides several of the settings to the compiler. What is changed by this varies with different chips, but will prevent the code from working in most cases....
Seriously, this has been talked about many times in the forum, and you implied in your first post that you had used normal CCS operation, and _also_ MPLAB, but it now looks rather as if you have in fact been using MPLAB all the time. |
|
 |
viki2000
Joined: 08 May 2013 Posts: 233
|
|
Posted: Mon Jun 03, 2013 5:41 am |
|
|
@Ttelmah
Some explanations to your statements/question:
1) I was aware of Debug/Release mode and was always done properly in MPLAB, meaning: when I had to program the chip in MPLAB, no matter if I used XC8, HITECH, CCS C compilers or ASM compiler – I used always Release. There are too many warnings in the software, only blind you do not notice. When I tried to debug in MPLAB with XC8, HITECH or ASM then I switched to debug mode. I was forced to do it; otherwise the Debugger is not working. There is no error here.
2) I want to clear specify one more time: there are no hardware errors of any kind, you will see below more info.
3) Maybe you are right and MPLAB does not do anything itself and only calls the CCS compiler, but I was thinking that under the skin of MPLAB, some of the settings for CCS call are not proper, because I found few weeks ago such problem with CCS C compiler plugin for MPLAX regarding the same PIC10F320. I reported it to Microchip and in 1 week they released a new version of plugin. See here: http://www.microchip.com.edgekey.net/forums/m723320-print.aspx . I am not saying is the same, but working in parallel with 2 PCs, one on 64 bits and one on 32 bits, various PIC microcontrollers and different C compilers, I had to take in consideration all the possible bugs. In fact, right now I believe is a different bug.
4) Did I use MPLAB all the time? No. But many times yes, and for a good reason.
a. This is just a personal experience, so you can understand the background of my questions.
b. Since many years I did not work with microcontrollers. I worked with networks of controllers, PLCs, of various kinds. Probably I have done 5-6years ago some hobby projects in BASIC with some PIC’s. Probably 15 years ago I learned ASM for 8051 some TMS chips…and I made a project for 8086 in C, data acquisition systems…after that I did not need it, I worked something else, but I have a certain background and knowledge, of course not comparable with most of the guys from here which have thousands of posts In forums.
c. Few months ago I started to work on some projects where a microcontroller was needed. Was the best option. I forgot about ASM a lot, but I knew some basic, C language. I searched and found something a lot easier: Flowcode, blocks. And I used it for a while with PIC16F88. Then I needed a smaller, cheaper microcontroller and during my visits to technical fairs I decided to go with MICROCHIP, at least for the moment. The PIC10F200 was the first option. Flowcode has it inside, but requires HITECH which does not work easy, needs all kind of additional settings, not only simply logic blocks. Then I decided to go for a real C compiler and I knew a bit about Hitech, MPLAB. Additional I found CCS. I tried few days to learn and I realized CCS is a lot easier for me now. And it worked for few good weeks.
d. At that time, when I worked only with PIC10F200, I used only PIC10F200; CCS compiler and Pickit3 programmer with its programming software from Microchip. And everything was fine. No MPLAB.
e. Due to nature of project 2 things came up:
i. The necessity of analog port and maybe external interrupt, because wake-on-port with PIC20F200 did not help me too much.
ii. The project has high voltage pulses on small PCB which may affect the wake-up state sometime.
iii. Because of the above reason(s) I needed to see what’s happening in real time inside to PIC brain, so I bought the header debugger for PIC10F200 and also for PIC10F320. And as you imagine, from here I was forced to work with MPLAB. So I tried also HITECH, in the beginning.
iv. When PIC10F320 came as new option, I was blocked again by its bugs and I tried also XC8, besides other C compilers. I worked on 2 PC’s with Win7 64 bits and 32 bits.
v. Maybe you understand now better, why I mention all the time MPLAB: because for Debug mode regarding PIC10F320 is the only option that I have.
vi. And there is one more thing: Pickit3 programmer standalone software. The initial version used by me supported only PIC10F2xx and Pic10F3xx was not listed. Instead, inside MPLAB I could burn easy also PIC10F3xx. Only with an application from Pickit3 Scripting, where is Pickit 2 more mentioned than Pickit3, but also an application Pickit3, I could choose and burn PIC10F3xx. It has downsides: new firmware download each time in Pickit3 programmer, then revert back the firmware for MPLAB for debugging… With MPLABX there is another application for burning: MPLAB IPE, but I did not notice in the beginning that you have to go in advance mode with password in order to set Import hex file for burning, With all these in my mind in short time, I had to try also HITECH and XC8 besides lovely CCS compiler. I really like CCS for its IDE, libraries...
To come back at original subject:
- 90% of the problem is solved.
What does it mean that?
The present problem was posted in the same time also on Microchip forum in the section of Hitech Compiler. Even if I had the solution for the cause of the problem in hands from beginning, I did not know where to look until somebody pointed out very clear. The problem was described on that Japanese website.
What is the problem: The RAMBANK=40-7F is wrong and RAMBANK=60-7F is right for PIC10F320.
I changed in the PICC.INI file of the HITECH and also of the XC8 (these 2 compilers seems twins anyway…) the RAMBANK=60-7F and everything worked normal.
There was no hardware problem, no Windows, no MPLAB version…nothing else, only RAMBANK.
I tried with PIC10F322 with all compilers, with and without MPLAB and works perfect.
The problem is only with PIC10F320.
And I know at least one more C compiler which is possible that may use same bad info:
http://www.bknd.com/cc5x/headers.shtml
Here is a list of C compilers: http://www.informel.de/pic/ccompiler.htm just for you to compare…
...when you think that everything started from bad documentation as datasheet, uncorrected since almost 1 year. I think all engineers which make C compilers for PIC10F320 used the same bad info from PIC10F320 datasheet.
To summarize:
- There was and there is NO problem with PIC10F322 using all these 3 compilers: HITECH, XC8 and CCS. I tried today.
- The problem with PIC10F320 and HITECH and XC8 is related with PICC.INI file: RAMBANK=40-7F is wrong and RAMBANK=60-7F is right, because that datasheet is wrong.
- Regarding CCS compiler I still have problems and I would like to discuss them below.
1) The CCS version used by me is 4.140 and is still not working using PIC10F320 in 2 ways:
a. C file written in CCS IDE, compiled in CCS IDE and then hex file burned with Pickit3 programmer.
b. C file written in MPLAB and burned on chip with Pickit3 inside to MPLAB
Now, you use command line compiler, different version than mine.
I would like to discuss about that.
2) Does anybody know: starting with what version of CCS compiler is PIC10F320 supported?
a. I tried 4.124 version and PIC10F320 is not listed under supported devices. As you mentioned 4.135, what about previous versions? Have a look here: http://www.ccsinfo.com/devices.php?page=versioninfo
b. In the above link, PCM version is mentioned few times with bug correction.
c. I see that are 2 types of CCS compilers: CCS IDE and CCS command line.
d. I always used CCS IDE and I am afraid the same datasheet bad info was implemented here too. But why not also for command line compilers then? A good question for me.
e. I watched the MPLAB and MPLABX calls of CCS:
i. From MPLABX:
"C:\PROGRA~2\PICC\CCSCON.exe" out="build/default/production" Blink.c +FM +DF +Y=9 +EA +DF +LN +T +A +M +J +EA +Z -P #__10F320=TRUE
ii. MPLAB:
"C:\Program files\Picc\CCSC.exe" +FM "BLINK.c" +DF +LN +T +A +M +Z +Y=9 +EA #__10F320=TRUE
I can only try to call CCS IDE as command line compiler as MPLAB does, but I need to know the syntax used by you with version 4.135, 4.141…
I would like to solve also the mystery behind CCS as was solved for HITECH and XC8 and I am afraid of similar root cause…
Last edited by viki2000 on Mon Jun 03, 2013 1:08 pm; edited 2 times in total |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9658 Location: Greensville,Ontario
|
|
Posted: Mon Jun 03, 2013 6:08 am |
|
|
hmm small PIC big problem....sigh..got any hair left?
regarding your comment...
'because for Debug mode regarding PIC10F320 is the only option that I have. '
Are you saying you haven't compiled in 'release' mode, burned a PIC, and tried it? You MUST recompile when switching from 'debug' to 'release'.
I know for a fact 'debug' mode will screw up the PIC code! I NEVER,EVER use 'debug' mode always 'release'. Currently using MPLAB 8v86, zero problems.Cut code in PCM,compile,burn(ICSP),test in real world.
Depending on the MPLAB version you can change the default from 'debug' to 'release'.MCHP sent me a patch ,few years back, as 'debug' was causing me no end of grief.
hth
jay |
|
 |
|
|
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
|