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

12F1822 + U-64 blink LED ... doesn't ? --[SOLVED .. mostly]

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



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

12F1822 + U-64 blink LED ... doesn't ? --[SOLVED .. mostly]
PostPosted: Mon Mar 03, 2014 5:06 pm     Reply with quote

compiler version 4.141
Debugger/programmer is U-64 (supplies power to target = 5v)
LEDs connected via 220 ohm resistor to RA4 and RA5 (just trying
to get RA4 (LED1) to work for now). Target does have 5v as
expected (installed jumper in U-64).

It seems to load OK (although not very fast). If I try to single
step, it starts with the arrow just below "main()" as expected.
Step causes it to point to "setup_comparator"
step causes it to point to "setup_oscillator"
step causes arrow to vanish.

Two items of interest - in main.h, where it indicates that
"this device not currently .... picwizard" - it had put the
string in there of "NC_NC_NC_NC", however according to the
devices file, it should be "NC_NC" which is what I put there
and it compiles with no errors. The other thing that I find
odd is that while the "setup_oscillator" indicates "OSC_1MHZ",
at the bottom of the debugger window it indicates
"Ready MCU at 0.50 MHz"

Just wanted to start with the simple blink an LED example since I
had not played with either the U-64 or the 12f1822 part before.
Obviously I am missing something - debugger gets lost and no
blinking. Pointers to what I am missing most welcome !!


Code:
//main.h
#include <12F1822.h>
#device ICD=TRUE
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(int=1000000)

#define LED1 PIN_A4
#define LED2 PIN_A5
#define DELAY 1000

// ============================================
//main.c
#include <main.h>


void main()
{
   setup_comparator(NC_NC);// This device COMP currently not supported by the PICWizard
   setup_oscillator(OSC_1MHZ|OSC_TIMER1|OSC_PLL_OFF,0);

   //Example blinking LED program
   while(true)
   {
      output_low(LED1);
      delay_ms(DELAY);
      output_high(LED1);
      delay_ms(DELAY);
   }

}

_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3


Last edited by gpsmikey on Mon Mar 03, 2014 8:45 pm; edited 1 time in total
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Mar 03, 2014 5:16 pm     Reply with quote

For what it's worth, here is the list file created - if I step through that file instead of the C source file, it makes it down to the last instruction before main of "CLRF 18" then vanishes.

Code:
CCS PCM C Compiler, Version 4.141, ????               03-Mar-14 14:49

               Filename:   F:\Embedded_Projects\Blink_LED_12f1822\main.lst

               ROM used:   57 words (3%)
                           Largest free fragment is 1991
               RAM used:   6 (5%) at main() level
                           21 (18%) worst case
               Stack:     1 locations

0000:  NOP
0001:  MOVLP  00
0002:  GOTO   011
.................... #include <main.h>
.................... #include <12F1822.h>
.................... //////// Standard Header file for the PIC12F1822 device ////////////////
.................... #device PIC12F1822
.................... #list
.................... 
.................... #device ICD=TRUE
.................... #device adc=16
.................... 
.................... #FUSES NOWDT                    //No Watch Dog Timer
.................... #FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
.................... #FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
.................... #FUSES NOMCLR                   //Master Clear pin used for I/O
.................... #FUSES NOBROWNOUT               //No brownout reset
.................... #FUSES NOIESO                   //Internal External Switch Over mode disabled
.................... #FUSES NOFCMEN                  //Fail-safe clock monitor disabled
.................... #FUSES DEBUG                    //Debug mode for use with ICD
.................... #FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... 
.................... #use delay(int=1000000)
0003:  MOVLW  20
0004:  MOVWF  05
0005:  MOVLW  06
0006:  MOVWF  04
0007:  MOVF   00,W
0008:  BTFSC  03.2
0009:  GOTO   010
000A:  MOVLW  52
000B:  MOVWF  20
000C:  DECFSZ 20,F
000D:  GOTO   00C
000E:  DECFSZ 00,F
000F:  GOTO   00A
0010:  RETURN
.................... 
.................... #define LED1 PIN_A4
.................... #define LED2 PIN_A5
.................... #define DELAY 1000
.................... 
.................... 
.................... 
.................... 
.................... 
.................... void main()
.................... {
0011:  MOVLW  5A
0012:  MOVLB  01
0013:  MOVWF  19
0014:  MOVLB  03
0015:  CLRF   0C
0016:  MOVLB  02
0017:  CLRF   12
0018:  CLRF   11
....................    setup_comparator(NC_NC);// This device COMP currently not supported by the PICWizard
0019:  CLRF   12
001A:  CLRF   11
....................    setup_oscillator(OSC_1MHZ|OSC_TIMER1|OSC_PLL_OFF,0);
001B:  MOVLW  59
001C:  MOVLB  01
001D:  MOVWF  19
001E:  CLRF   18       <<<<<=== debugger vanishes after executing this one.
.................... 
....................    //Example blinking LED program
....................    while(true)
....................    {
....................       output_low(LED1);
001F:  BCF    0C.4
0020:  MOVLB  02
0021:  BCF    0C.4

_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Mar 03, 2014 7:29 pm     Reply with quote

OK, it seems to be working - if I take out the line for "setup_oscillator()" and let the "#use delay" statement in the .h file stand, it initializes and runs as expected. Not too impressed - I had tried the simple "blink LED" program from within the wizard. The wizard apparently not only got the oscillator setup wrong in that statement, but also got confused on configuring the comparators. I think the "wizard" is wearing a dunce cap.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 03, 2014 9:09 pm     Reply with quote

Quote:
setup_oscillator(OSC_1MHZ|OSC_TIMER1|OSC_PLL_OFF,0);

The Wizard has selected Timer1 as the system clock source, and
Timer1 isn't running.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 4:46 am     Reply with quote

Thanks PCM - I thought I had picked the simplest options available in the "wizard" when I ran it and selected the simplest 1mhz clock. Apparently not although one of the things that threw me off was when the wizard could not figure out what to do with the comparators (although it did leave a comment to that effect). Oh well, the blinking thing is working now - on ahead with adding features and hardware. I wasn't sure initially just what part of my configuration was not working since I had not used that chip or the U-64 before (and the documentation on the U-64 is very close to none ). I wish there were a good tutorial on using the U-64 (I found one in Spanish, but virtually nothing in English).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
jeremiah



Joined: 20 Jul 2010
Posts: 1355

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 10:32 am     Reply with quote

Depends on what you want a tutorial on. CCS has some video tutorials on their website for some of the fancier options.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 10:47 am     Reply with quote

When I looked around their website ( http://www.ccsinfo.com/content.php?page=video_tutorials ) the only one I could find targeting the U-64 was the one near the bottom labeled "ICD-U64 Example (Video in Spanish)". If anyone has a pointer to a decent tutorial on the U-64, I would appreciate a link to it. They really need to provide it with a manual that covers some basic setup (and the jumpers for providing target voltage) etc. They do have some stuff in the FAQ like the hookup etc. but there are some basics they should cover as well as guidelines for what it can support and what it does not support - one example, I found another users post (and he confirmed it) indicating that too large a cap on the 5v (or 3.3v) bus can blow the programmer (for battery stuff I like to have a 47 ufd in parallel with a .1 ceramic close to the chip). It is strange that they would have a Spanish version of the tutorial on their site, but not an English version (do I need to "push 1 for English" ? )
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
jeremiah



Joined: 20 Jul 2010
Posts: 1355

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 11:38 am     Reply with quote

The data streaming video as well as a few others on that page target the U-64 (they just don't have u-64 in the name) and are in English. They aren't basic setup tutorials.

You mentioned jumpers. My U-64 doesn't have any jumpers. Are you looking at a dev kit for those?

They could definitely use some easier to find documentation on the device.
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 11:45 am     Reply with quote

The classic caveat, is one often repeated here. "Don't trust the Wizard". It can work perfectly competently, but does _not_ check things.

The key here is that if you don't touch the 'Intr Oscillator Config' page, and just select the internal oscillator in the first screen, the Wizard will get it completely right. However if you select the Intr Oscillator page, there is a separate 'system clock select' block, which defaults to Timer1....

Best Wishes
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Wed Mar 05, 2014 2:27 am     Reply with quote

Thanks Ttelmah - that was probably what I did trying to make sure I had it set to simple. I have added your comment to my notes Very Happy

jeremiah - actually, I think yours probably has the jumper for power as well - you have to pry the silly case open (I found it mentioned on one of their pages somewhere) and there is a 3 pin jumper you use if you want to select to power the target at either 3.3v or 5v. See this page on the connection information: http://www.ccsinfo.com/faq.php?page=connect_icd - the second paragraph under the connection table states that
Quote:
"Another reason is because the ICD-U is capable of supplying +3.3V or +5.0V to the target board. This can be done by opening the case of the ICD-U and placing a jumper on the correct jumper pins next to the ICD connector."


mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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