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 support@ccsinfo.com

Serial data setup for dual channel D/A

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 13, 2006 11:03 am     Reply with quote

Before you do anything else, disable the Low Voltage Programming mode.
Add the parameter shown in bold below.
Quote:
#fuses HS,NOWDT,NOPROTECT, NOLVP


There are three very important "essentials" that you should do
in every CCS program.

1. Add NOLVP to the #fuses statement.

This prevents the PIC from locking up if you take the PGM pin high.
The PGM pin is typically pin B3 or B5. This assumes that your PIC
supports LVP mode and has a PGM pin - not all of them do.


2. Add ERRORS to your #uses rs232() statement.

This prevents the UART from locking up if you get a receive
overrun error. This parameter only works with a hardware UART.


3. Add a while(1) statement at the end of main().

This prevents the program from executing a hidden SLEEP instruction
that the compiler inserts at the end of main(). If that instruction
is executed, the PIC will stop running. Any characters that were
hardware UART's transmit buffer will not be sent.
JimB



Joined: 25 Aug 2005
Posts: 65
Location: Huntington Beach, CA

View user's profile Send private message

PostPosted: Thu Apr 13, 2006 11:30 am     Reply with quote

Since I am running this project from 3V, don't I need to exclude that fuse?
Pin B3 is devoted only to programming and the MCLR pin is isolated with a resistor and a Schotky diode.
I have had some problems with the computer's USB port going to the ICD and have had to remove the cable and let it re-initialize.

Jim
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 13, 2006 11:36 am     Reply with quote

1. Are you using a Low Voltage Programmer ?
If not, then you need the NOLVP fuse.

2. Are you using the "LF" version of the 16F877A ?
You need to use that version if you're running at 3 volts.

3. Is the diode in series with the MCLR resistor ?
You don't need a diode, provided that you use a 10K resistor
on MCLR. (Use 47K with CCS ICD).
JimB



Joined: 25 Aug 2005
Posts: 65
Location: Huntington Beach, CA

View user's profile Send private message

PostPosted: Thu Apr 13, 2006 12:49 pm     Reply with quote

I am using the CCS ICD-U40. The chip is the "LF" version. The diode is connected in series with the 47K resistor going to the MCLR* pin. I thought the diode would protect all of the other LV devices on the board.
I was assured by CCS that this programmer would interface with the 3V logic OK.
I have had some peculiar issues with the ICD. It always erases the EEPROM on the 3V board, even though the setting is for no erase but it works OK on the 5V development board. Depending on whether or not I run ICD from within the CCS compiler, under the "tools" menu and when I run it from the ICD shortcut in the Start, Programs" menus in WinXP. I sometimes get different results.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 13, 2006 1:17 pm     Reply with quote

Quote:
I am using the CCS ICD-U40

The ICDU40 is a high voltage programmer. Therefore, you should
use the NOLVP fuse setting.

Quote:

The diode is connected in series with the 47K resistor going to the MCLR*
pin. I thought the diode would protect all of the other LV devices on the
board.

Assuming that the circuit has Vdd (+3v in your case) applied to it
while the Vpp is applied, the diode shouldn't be necessary.
With a 47K resistor, you'll have +13v on one side, and +3v on the other.
That's a 10v drop across the resistor. The current through it is 10v/47K
which is 0.2 ma. The voltage regulator on the Vdd side will easily be
able to maintain regulation of the +3v, even though 0.2ma is being
sourced into the Vdd supply through the resistor.

The only way there would be a problem is if Vpp were turned on
without the target board being powered. But I don't think that
ever happens.

Go to this CCS page and scroll down to the circuit diagram.
They don't show a diode.
http://www.ccsinfo.com/faq.php?page=icd_connection

If you use a diode, you block the path for any positive ESD voltage
to bleed off into the Vdd power supply. If you use a silicon diode
(instead of a Schottky), then you reduce the margin of the MCLR
voltage above the spec'ed minimum Vih value.
JimB



Joined: 25 Aug 2005
Posts: 65
Location: Huntington Beach, CA

View user's profile Send private message

Up and running except for..........
PostPosted: Sat Apr 15, 2006 1:54 pm     Reply with quote

Questions?

First of all thanks again for the help.

1. Could you expand on your comment about using "error" in the #use RS232(debugger) line. Could not find any reference to this.

2. Should one be able to interchange the SHIFT_LEFT and ROTATE_LEFT, i.e.
output_bit(maxdat, shift_left(&vref,2,0));
output_bit(maxdat, rotate_left(&vref,2));
I am not having success with rotate_left function.

3. If vref, in 2 above, is only an int8, would one use a 1 or a 2 if there are 16 shifts and vref needs to be the MSB? The compiler manual implies that a 1 is the correct answer. I changed vref to int16 for it to work properly but would like to keep it at int8. Less code required when reading from the eeprom.

4. When running from the development board (+5V) the debugger monitor works pretty good. (Just little glitches now and then.) But when operating with the real hardware (+3V) there is no response on the monitor nor does the "No erase the eeprom" work correctly. Have searched for help with this on this board and the CCSC website with no results.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 16, 2006 3:58 pm     Reply with quote

Quote:
1. Could you expand on your comment about using "error" in the #use RS232(debugger) line. Could not find any reference to this.
It doesn't apply to the debugger output.


Quote:
I am not having success with rotate_left function.
If vref, in 2 above, is only an int8, would one use a 1 or a 2 if there
are 16 shifts and vref needs to be the MSB? The compiler manual
implies that a 1 is the correct answer.

An int8 only has 8 bits. If you do more than 7 shift-left operations,
you will shift all bits out of the int8 variable. The variable would then
become 0 (Assuming the "shift in" value is specified as 0).
If this answer doesn't help, then post a very small but complete test
program that shows the problem. Post all variable declarations.



Quote:
When running from the development board (+5V) the debugger monitor works pretty good. (Just little glitches now and then.) But when operating with the real hardware (+3V) there is no response on the monitor

I don't have the CCS ICD so I can't really help. My advice is to search
the Programmer/Debugger forum for hints. If that doesn't work, then
call CCS support on the telephone (instead of emailing them).
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