Right time for an update.
Problem solved and everythings happy. I ended up writing a little function to solve my woes and it went something like this.
Code:
void WriteInt2LCD(int writeInt, int writeCol, int writeRow)
{
unsigned int i;
char Parsed2Int[7]; //declare string variable
char LetterBuffer; //this is our typewriter
InttoStr(writeInt,Parsed2Int); //do conversion
//now perform a loop, writing character by character to lcd
for (i=0; i<7; i++) //for i = 0 to 7, increment by 1
{
if (Parsed2Int[i] != ' ') //check for null character?
{
LetterBuffer = &Parsed2Int[i]; //send letter to LetterBuffer
Lcd_Out(writeRow, writeCol, LetterBuffer); //write text
writeCol++; //increment cursor
}//end of 'if'
}//end of for loop
}//end of function
I appreciate it's not very tidy, but now I can just throw my function an integer and it'l 'type it out' left justified and miss out all the null characters. Happy days.
Beleive it or not that's my first ever function. LOL.
Anyway, good stuff. (for now). Next question.
I use mainly the pic16f673a, pic16f877a for my bigger projects, but I'm also a fan of the 12f675 and 12f683 for smaller projects. So in my bid to get accustomed with mikroC I made a simple experiment in Proteus and started writing a small program that would illuminate a bulb with a logic 'fet when a switch is pressed. Here's the circuit.
**broken link removed**
As you can see it's a simple affair. Not to criticise my own work too much - it works.
So if I set up the pic 12f in C and set GPIO bit 2 high, the bulb lights up. It does.
If you clear the bit, and run the simulation, the light does not come on.
However, when i coded an example that would light the lamp when the switch on GPIO bit 0 was set (high), it does not react.
I have taken care to disable the adc module, and set ports digital.
Bearing this in mind, and somewhat assuming I did so correctly, I beleive either my input detection logic is incorrect, or proteus is not simulating the software correctly (it happens!).
Here's the code for selecting digital, disabling adc etc:
Code:
//set chip up
//disable adc
ADCON0.B0 = 1;
ANSEL.B0 = 0;
ANSEL.B1 = 0;
ANSEL.B3 = 0;
//set pins direction - two out, three in.
TRISIO.B0 = 1;
TRISIO.B1 = 1;
TRISIO.B2 = 0;
TRISIO.B3 = 1;
TRISIO.B4 = 0;
And finally, the switch detection!
Code:
// MAIN LOOP
while (1){
if (GPIO.b0=1){
GPIO.B2 = 1;
}
}
^^^ Epic isn't it!!!
I'm aware that there is no debounce routine. I haven't got that far yet, even a bouncy switch would be a plus!
So the question is, not so much 'whats wrong?' but rather 'surely that should work?'
happy days.