Searching \ for '[OT]: CCS C COMPILER' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/language/index.htm?key=c
Search entire site for: 'CCS C COMPILER'.

Exact match. Not showing close matches.
PICList Thread
'[OT]: CCS C COMPILER'
2000\06\13@153336 by WF

flavicon
face
Hi

How can i write in C an instruction  that writes in the LOW NIBBLE of
PORTB??? OR HIGH NIBBLE?

Thanks!

Miguel

2000\06\13@154415 by Andrew Kunz

flavicon
face
PORTB = (PORTB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble

PORTB = (PORTB & 0xF0) | (NEWVALUE & 0x0F);   // Updates low nybble

Andy

2000\06\13@155010 by WF

flavicon
face
My question is:

Will affect the remainder bits? The remainders bits are configurated as
INPUT and OUTPUT...

Miguel
----- Original Message -----
From: Andrew Kunz <spam_OUTakunzTakeThisOuTspamTDIPOWER.COM>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Tuesday, June 13, 2000 4:42 PM
Subject: Re: [OT]: CCS C COMPILER


> PORTB = (PORTB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble
>
> PORTB = (PORTB & 0xF0) | (NEWVALUE & 0x0F);   // Updates low nybble
>
> Andy

2000\06\13@155529 by Andrew Kunz

flavicon
face
It depends on how much you are draining/sourcing through the pins.

If you want to be sure, you need to use shadow registers instead of directly
reading the hardware.

UINT8     shadowB;

shadowB = (shadowB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble
PORTB = shadowB;    // Send updated shadow to hardware

Andy










WF <wfspamKILLspamBLUSOFT.ORG.BR> on 06/13/2000 03:42:33 PM

Please respond to pic microcontroller discussion list <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>








To:      EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU

cc:      (bcc: Andrew Kunz/TDI_NOTES)



Subject: Re: [OT]: CCS C COMPILER








My question is:

Will affect the remainder bits? The remainders bits are configurated as
INPUT and OUTPUT...

Miguel
----- Original Message -----
From: Andrew Kunz <akunzspamspam_OUTTDIPOWER.COM>
To: <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Tuesday, June 13, 2000 4:42 PM
Subject: Re: [OT]: CCS C COMPILER


> PORTB = (PORTB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble
>
> PORTB = (PORTB & 0xF0) | (NEWVALUE & 0x0F);   // Updates low nybble
>
> Andy

2000\06\13@155940 by M. Adam Davis

flavicon
face
It will affect the output bits, but not the inputs.  All the bits are read in
the first instance, then the high or low value of the bits you are keeping are
re-written to portB, along with the low or high value of the bits your are
writing to portb.

This can cause a problem in this way:
Say you've set bit 7 as output, and are driving it high.
If an external load is driving the pin low (and doing a better job than the PIC)
then when you read in PORTB it will report that that pin is low, even though you
previously told it to output high.  When you write the modified value back to
the port it will set that pin low.

See the instructions BCF and BSF from the data sheet.  In a nutshell, ports do
not exist as registers.  If you only modify a portion of a port you will read
the actual value on the pin, not the intended value.

-Adam

WF wrote:
{Quote hidden}

2000\06\13@161218 by WF
flavicon
face
You are correct...today i do BIT manipulation...but, i want to reduce my
code...
----- Original Message -----
From: M. Adam Davis <spamBeGoneadavisspamBeGonespamUBASICS.COM>
To: <TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU>
Sent: Tuesday, June 13, 2000 4:59 PM
Subject: Re: [OT]: CCS C COMPILER


> It will affect the output bits, but not the inputs.  All the bits are read
in
> the first instance, then the high or low value of the bits you are keeping
are
> re-written to portB, along with the low or high value of the bits your are
> writing to portb.
>
> This can cause a problem in this way:
> Say you've set bit 7 as output, and are driving it high.
> If an external load is driving the pin low (and doing a better job than
the PIC)
> then when you read in PORTB it will report that that pin is low, even
though you
> previously told it to output high.  When you write the modified value back
to
> the port it will set that pin low.
>
> See the instructions BCF and BSF from the data sheet.  In a nutshell,
ports do
> not exist as registers.  If you only modify a portion of a port you will
read
{Quote hidden}

2000\06\16@042351 by WF

flavicon
face
You are correct...today i do BIT manipulation...but, i want to reduce my
code...
----- Original Message -----
From: M. Adam Davis <EraseMEadavisspamUBASICS.COM>
To: <RemoveMEPICLISTEraseMEspamEraseMEMITVMA.MIT.EDU>
Sent: Tuesday, June 13, 2000 4:59 PM
Subject: Re: [OT]: CCS C COMPILER


> It will affect the output bits, but not the inputs.  All the bits are read
in
> the first instance, then the high or low value of the bits you are keeping
are
> re-written to portB, along with the low or high value of the bits your are
> writing to portb.
>
> This can cause a problem in this way:
> Say you've set bit 7 as output, and are driving it high.
> If an external load is driving the pin low (and doing a better job than
the PIC)
> then when you read in PORTB it will report that that pin is low, even
though you
> previously told it to output high.  When you write the modified value back
to
> the port it will set that pin low.
>
> See the instructions BCF and BSF from the data sheet.  In a nutshell,
ports do
> not exist as registers.  If you only modify a portion of a port you will
read
{Quote hidden}

2000\06\16@044055 by M. Adam Davis

flavicon
face
It will affect the output bits, but not the inputs.  All the bits are read in
the first instance, then the high or low value of the bits you are keeping are
re-written to portB, along with the low or high value of the bits your are
writing to portb.

This can cause a problem in this way:
Say you've set bit 7 as output, and are driving it high.
If an external load is driving the pin low (and doing a better job than the PIC)
then when you read in PORTB it will report that that pin is low, even though you
previously told it to output high.  When you write the modified value back to
the port it will set that pin low.

See the instructions BCF and BSF from the data sheet.  In a nutshell, ports do
not exist as registers.  If you only modify a portion of a port you will read
the actual value on the pin, not the intended value.

-Adam

WF wrote:
{Quote hidden}

2000\06\16@051654 by Andrew Kunz

flavicon
face
It depends on how much you are draining/sourcing through the pins.

If you want to be sure, you need to use shadow registers instead of directly
reading the hardware.

UINT8     shadowB;

shadowB = (shadowB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble
PORTB = shadowB;    // Send updated shadow to hardware

Andy










WF <wfSTOPspamspamspam_OUTBLUSOFT.ORG.BR> on 06/13/2000 03:42:33 PM

Please respond to pic microcontroller discussion list <spamBeGonePICLISTSTOPspamspamEraseMEMITVMA.MIT.EDU>








To:      KILLspamPICLISTspamBeGonespamMITVMA.MIT.EDU

cc:      (bcc: Andrew Kunz/TDI_NOTES)



Subject: Re: [OT]: CCS C COMPILER








My question is:

Will affect the remainder bits? The remainders bits are configurated as
INPUT and OUTPUT...

Miguel
----- Original Message -----
From: Andrew Kunz <EraseMEakunzspamEraseMETDIPOWER.COM>
To: <@spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU>
Sent: Tuesday, June 13, 2000 4:42 PM
Subject: Re: [OT]: CCS C COMPILER


> PORTB = (PORTB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble
>
> PORTB = (PORTB & 0xF0) | (NEWVALUE & 0x0F);   // Updates low nybble
>
> Andy

2000\06\16@055447 by WF

flavicon
face
My question is:

Will affect the remainder bits? The remainders bits are configurated as
INPUT and OUTPUT...

Miguel
----- Original Message -----
From: Andrew Kunz <spamBeGoneakunzspamKILLspamTDIPOWER.COM>
To: <.....PICLISTspam_OUTspamMITVMA.MIT.EDU>
Sent: Tuesday, June 13, 2000 4:42 PM
Subject: Re: [OT]: CCS C COMPILER


> PORTB = (PORTB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble
>
> PORTB = (PORTB & 0xF0) | (NEWVALUE & 0x0F);   // Updates low nybble
>
> Andy

2000\06\16@061746 by Andrew Kunz

flavicon
face
PORTB = (PORTB & 0x0F) | (NEWVALUE & 0xF0);   // Updates high nybble

PORTB = (PORTB & 0xF0) | (NEWVALUE & 0x0F);   // Updates low nybble

Andy

2000\06\16@061959 by WF

flavicon
face
Hi

How can i write in C an instruction  that writes in the LOW NIBBLE of
PORTB??? OR HIGH NIBBLE?

Thanks!

Miguel

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...