Expert configuration and 16F630

Forum for problems or queries regarding the Flowcode application and compiler usage.

Moderators: Benj, Mods

Post Reply
stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Expert configuration and 16F630

Post by stylo »

Need some help please !

I would first like to congratulate you on FlowCode; it's a great programme, can't wait for V4 to be out.

I am relatively new to programming but have managed to successfully build an 'Iambic Morse keyer' circuit (produces perfectly spaced Morse dots and dashes depending which way you move a paddle). The initial successful chip used was a PIC 12F629.

The problems started when I needed to have more I/O pins to accommodate programmed call signs, CQ and the like, that would be initiated from external push buttons, so I re-wrote the programme for the PIC 16F630, but although the programme compiles and runs as intended I am unable to get any response from the two inputs RA1 and RA0, Pins 12 and 13. They are both capable of being inputs according to the spec sheet. My suspicion is it may have something to do with these pins being the inputs for the internal comparator, BUT how do I activate them to be inputs using Expert Configuration?

While I'm on the subject of 'Expert Configuration' is there some information on this aspect of FlowCode that I can down-load or buy? It took me days of trial and error, frustration and a few sleepless nights to get the above almost fully working.

The programme is a loop with two inputs; one for dots and one for dashes. Each input is followed by a decision, which initiates a Macro; one Macro forms the dot followed by a space and the other Macro forms the dash followed by a space.

Both Macros output to pin 7, RC3, and then to a sounder and a switching circuit to the transmitter.

All but two of the other pins are inputs to similar decision and initiation of the macros but in this case they are in groups of dash and dot macros with spaces to give Radio Ham call signs on some inputs and the letters for CQ on another, etc.etc. The two outputs on RA4 and RC5 are Re-sets for a pair of external flip flops that form a memory, so if you speed ahead of the system and call for a dot while the dash is still playing the flip flops remember and stop you losing the dot. The same applies for the dash. Hope this makes some sense!

FlowCode V 3.2.2.40 Professional.

EXPERT CONFIG SETUP

Chip: 16F630
Clock: 4 Meg
Oscillator: External RC no clock
W D Timer: off
Power up timer: off
Master clear: Internal
Brown out Detect: on
Code protect: off
Data EE read project off
Band gap Cal V: Highest voltage

Pin 1: Vdd
Pin 2, OSC1 RC Connection
Pin 3, RA4 Output (DOT Mem Re-set)
Pin 4, RA3,MCLR Input (Check DOT input) Must be input!
Pin 5, RC5 Output (DASH Mem Re-set)
Pin 6, RC4 Input (Check DASH input)
Pin 7, RC3 Output (to sounder)

Pin 8, RC2 Input
Pin 9, RC1 Input
Pin 10, RC0 Input
Pin 11, RA2 Input
Pin 12, RA1 Input (INOPERATIVE) this is the problem, needs to be an input
Pin 13, RA0 Input (INOPERATIVE) same as above, needs to be an input
Pin 14, Vss

I would greatly appreciate your help please.

Stylo

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Expert configuration and 16F630

Post by Benj »

Hello Stylo

Ok first things first. If you need to find out more about the expert configuration settings then please look at the section of the data sheet entitled "Special features of the CPU" Then click on "Configuration Bits". This section then lists all the settings and how to configure the external circuitry to match your settings. If you need to find the datasheet the simply type PIC followed by the device name into Google. in this case it would be "PIC16F630"

I noticed you are using an external RC oscillator. You may be better off using a external crystal as the RC oscillator will fluctuate with temperature and pressure etc. This would then have the knock on effect of skewing your output morse signals.

Simply using the input icon in Flowcode will convert the I/O pins to inputs. The comparator should not be affecting this functionality unless you have manually switched it on. If you have switched it on then check your settings. Check your switch hardware are you using pull up or pull down resistors or are you leaving the I/O pin floating when the switch is not pressed?

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Expert configuration and 16F630

Post by Steve »

Flowcode should turn off the comparator and adc modules by default, so these pins should default to i/o lines. But the test program I've just created does not seem to have the appropriate code. I'll ask someone here ot look into this today.

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: Expert configuration and 16F630

Post by stylo »

Hi Steve,

Just seen your reply to my query. Thanks for getting involved, I think I'll hold on till I hear back from you, but in reply to Benj's comments that I would be better off using a crystal instead of RC for the oscillator, the choice of using external RC to clock the chip was to vary the speed of the Morse by varying the speed of the clock to give 5 words to 30 words per minute, using a 20K Pot and 10pf on Osq1, It works fine.

I await developments, Thanks again.

Stylo

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: Expert configuration and 16F630

Post by stylo »

Attn. Steve, Matrix Multimedia.

Hi Steve,

As I have not heard from you regarding the dead pins, RA0, RA1 on the 16F630, I suspect that FlowCode default may have programmed them as one of the eight possible comparator modes, 000 to 111 instead of I/O pins.

Question: If these pins are programmed by FlowCode's input default mode as one the comparator configurations, instead of I/O pins, then can I reconfigure them by accessing and changing the CMCON Register?

I understand there are eight possible modes for the comparator; the first two are 000 (comparator reset) and 111 (comparator off). I suspect that my chip is in the comparator off mode ?

Your input would be most welcome.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Expert configuration and 16F630

Post by Benj »

Hello Stylo

Please can you look at the C code generated from your Flowcode program. Scroll to near the bottom of the code file and you will find the Main section of code. It should look like this.

void main()
{
//Initialisation
cmcon = 0x07;

The line you are looking for is the cmcon register. This should be given the value 7 or 0x07 to disable the comparitor module. If your value is different from 7 or you do not have the line of code then you can add it to a C code block at the start of your program.

cmcon = 0x07;

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: Expert configuration and 16F630

Post by stylo »

Hi Benj

Sorry for the long delay in getting back to you (was called away on other business).
Have added you're suggested C block and it worked first time.
Many thanks for your help.

Regards, Stylo

Post Reply