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

Error identifier and/or declaration for PORT_X_PULLUPS

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



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

Error identifier and/or declaration for PORT_X_PULLUPS
PostPosted: Sun Feb 05, 2012 6:54 pm     Reply with quote

Code:
#include <12F509.h>

#device *=8
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC                      //Internal RC Osc
#FUSES PROTECT                  //Code protected from reads
#FUSES NOMCLR                   //Master Clear pin used for I/O

#use delay(clock=4MHz)

#use STANDARD_IO( B )
port_B_pullups(TRUE);

#RESERVE  0x10:0X1F        //stack0
#RESERVE  0x30:0X3F        //stack1


...In my header file for configuration I want to use internal pullup's
I have error's "28" and "43" for Pullup
Where I must to write configuration Pullup? and how?
Version is 4.129

Why in new Version 4.129 vs. 4.084 I can't select:
- mclr or nomclr? (in Wizard configuration) (this bug appears an in other devices wizard)
Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 05, 2012 8:29 pm     Reply with quote

Quote:
#use STANDARD_IO( B )
port_B_pullups(TRUE);
#RESERVE 0x10:0X1F //stack0
#RESERVE 0x30:0X3F //stack1

Are you really putting that line out in space like that ? It belongs in
a function. Normally, it would be put near the start of the main() function.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Mon Feb 06, 2012 3:54 am     Reply with quote

Thanks PCM Programmer.
This information I found it nowhere.
When I use standard output for that port's, and return to input I must call again this function Port_X_pullups(TRUE) to have continous input with pullup?
About:
mclr or nomclr? (in Wizard configuration)
for now solving problem is to write manual?
Regards.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Feb 06, 2012 4:48 am     Reply with quote

The data sheet....
This really has to be the 'bible' for all such things. The manual describes the CCS functions, but what they actually 'do' is defined by the hardware.

On the pull-ups, no. Once set, they stay set until you clear them. They are automatically disabled when the TRIS bit on a pin is set to 0 (using the pin as an output), but will come on automatically when the pin switches back to being an input. This is described in the data sheet.

MCLR, is an input pin on the chip, which can be used as the 'master clear' input, _or_ as an I/O pin. There is a fuse that configures this (data sheet), and this is turned on/off by the CCS fuse settings MCLR and NOMCLR.

So both question have their answers in the data sheet.

In CCS, the 'essential reading' is:

1) Chip's data sheet.
2) CCS manual.
3) fuses.txt and readme.txt in the compiler directory.
4) A basic 'C' reference book (K&R).

Best Wishes
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Mon Feb 06, 2012 11:10 am     Reply with quote

I know very well datasheet for device Ttelmah
on page 3 or 7 or other pages (pullup).
MCLR in older version was in wizzard's.
Mclr and pullup seems to be a bug.

I try code:
Code:
void main()
{
port_B_pullups(TRUE);

   while(TRUE)
   {
      //TODO: User Code
   }

}

... I have Error"12" Undefinided indentifier -- port_B_pullups

Ttelmah try tris code on version 4.129 if you think it's my mistake and you see what I mean.
Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 06, 2012 5:52 pm     Reply with quote

On some of the low-end PICs you need to use the OPTION register to
enable pull-ups or other features. Try the program shown below.
Refer to the OPTION register explanation in the 12F509 data sheet for
more information.
Code:

#include <12F509.h>
#fuses INTRC,NOWDT,NOPROTECT,NOMCLR
#use delay(clock=4M)

#define set_options(value)   {#ASM         \
                              MOVLW  value \
                              OPTION       \
                              #ENDASM}
 
//======================================
void main()
{
set_options(0b10011111);  // Use GP2 for i/o, and enable pullups

while(1);
}
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Tue Feb 07, 2012 11:34 am     Reply with quote

Thanks PCM Programmer
yes this is what I need.
on page 24 is ... and already I known.
can you explain that code do you are use?
I want to understand for future use easy only documentation and programmer.

Code:
#define set_options(value)   {#ASM         \
                              MOVLW  value \
                              OPTION       \
                              #ENDASM}
set_options(0b10011111);  // Use GP2 for i/o, and enable pullups


GP2 have not PULL-UP enable GP0,GP1,GP3 are enable.
maybe because only GP0,GP1,GP3, have PULL-UP documentation is on page 24.

Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 07, 2012 12:43 pm     Reply with quote

It's explained in the 12F509 data sheet, how to load the OPTION register.
First load the 'W' register with MOVLW. Then copy 'W' to the OPTION
register with the OPTION instruction:
Quote:

4.5 OPTION Register

The OPTION register is a 8-bit wide, write-only register,
which contains various control bits to configure the
Timer0/WDT prescaler and Timer0.
By executing the OPTION instruction, the contents of
the W register will be transferred to the OPTION register
.
A Reset sets the OPTION<7:0> bits.

The GP2 part is a "freebee". It's not associated with enabling pull-ups.
To use GP2 as an i/o pin, you need to disable it as an external clock pin.
Most people want it as an i/o pin, so I just added that part in the code to be nice.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Tue Feb 07, 2012 1:18 pm     Reply with quote

ohh
Yes "option" is name of register 4.3.
Until now in my mind was function example like "IF" but in assembler code Embarassed
This is my best example/ lesson in programing.
Thanks.
regards
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Thu Mar 21, 2013 1:00 pm     Reply with quote

Why this function is not working?
Code:
...
#byte OPTION = 0b10011111
void main()
{
...

is not the same as the top function?
On compiler I do not have error's
thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 21, 2013 1:53 pm     Reply with quote

Read the CCS manual on the #byte statement. Read the PIC data sheet
on how to access the OPTION register for your PIC.

Don't expect us to do these things for you, when you could do it yourself.
The answers you want are in the CCS manual and PIC data sheet.
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Thu Mar 21, 2013 1:56 pm     Reply with quote

#byte specifies a location, not a value (like you are trying to do). To access the option register on this chip, you cannot use #byte as it has no known location. You need to use the assembly command OPTION, so you need to look at the data sheet for examples on that. Then in the compiler manual help, look for #asm and #endasm for how to use those.

EDIT: PCM Programmer beat me to it!
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Thu Mar 21, 2013 11:19 pm     Reply with quote

jeremiah
Thank you for your information.
I understand now.

PCM programmer
Thanks, what I need your experience to understand some problems for me.
example of jeremiah is best for me.

Thank you guys.
Nailuy.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Mar 22, 2013 3:32 am     Reply with quote

Lets make something clear here, you don't need to fiddle with assembler.

The option register on these chips, is accessed via the setup_wdt function in CCS.
The code to enable them if required, is simply:

Code:

void main(void) {
   setup_wdt(0);

}

which generates:
Code:

0003:  CLRF   07
0004:  CLRF   01
0005:  MOVLW  0F
0006:  OPTION
0007:  CLRWDT
0008:  MOVF   07,W
0009:  OPTION


Doing the required assembler to turn this on.

The reason there is not an 'option' to turn them on in CCS, is that the bit is negative logic, with a '1' turning this off. As soon as you program the timer/watchdog prescaler they are turned _on_ unless you add the option:
DISABLE_PULLUPS

The same applies for pin change from sleep.

As a further comment though, these are foul little chips. Why not get something like the PIC12F1501, which is cheaper now, especially in bulk, and has so many more resources. Makes life a lot easier....

Best Wishes
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