Gobbledok, it is is important for me to point out that you can say something like PORTAbits.RA0 = 1 to set RA0 to logic 1, or PORTAbits.RA0 = 0 to clear RA0. It is not only for reading a bit.
Yes, in C18 you use the format of PORTAbits.RA0 to control RA0, PORTBbits.RB4 to control RB4, etc.
Gobbledok, it is is important for me to point out that you can say something like PORTAbits.RA0 = 1 to set RA0 to logic 1, or PORTAbits.RA0 = 0 to clear RA0. It is not only for reading a bit.
Regards, and happy 2012!
Der Strom
Funny how this is not mentioned in the other thread (https://www.electro-tech-online.com/threads/c18-structure-for-bits.94878/).
Of course that is not a compiler feature. Those definitions are in the library. But then again, probably every C18 user pretty much have the same libraries.
void Function(char dat){
dat = 0x45;
}
char Passed=0x23;
Function(&Passed);
//Passed = 0x23
void Function(char *dat){
*dat=0x45;
}
char Passed=0x23;
Function(&Passed);
//Passed will now equal 0x45
void ScrollDisplay(){
char i,j,chr;
for(i=0;i<20;i++){ //start of for in column 4
for(j=0;j<3;j++){ //start of for in column 8
SetPos(i,j+1);
chr=ReadChar();
SetPos(i,j);
WriteChar(chr);
} //end also in column 8
} //end also in column 4
SetPos(0,3);
for(i=0;i<20;i++)
WriteChar(' ');
SetPos(0,3);
}
I have not looked at your code in depth, but appears like you were getting some quality help on the other forum. Lots of bit toggling going on, and plenty of places to get caught out.like i said none of it has been a real problem, I really do like that little compiler espically since it sets up so easially(w hdw settings included)
except for B) , i am not loosing track of the "LOOP NESTING" but GCGB is, and i find that during the compiler, you need to watch where it will just stop and close without an error, but no hex file either, so if there is old one there; it(obviously) doesn't get overwritten. if you look in my main, my loops are made with variable counts inside a main loop, where i would have liked to just use a few FOR statements. Again I "think" it may have to do with too many subroutines and loops and such.
a)exactly
c)all good, it doesnt really effect anything, FYI - the error shows when i import on the pickit2 programmer (but only that chip type)
D)scared of manual!! I like objects due to poor spelling an punctuation, (which is going to kill me in c!)
E)again no biggie just adds another line
F) * update i found the problem in my code on the other forum; variable BLOCKEE was just acting out;
thnx again thou everyone!; im definitely going to try out the c, now that 'v learned this new lang anyway!
um, actually it doesn't work, and doogle was great help, espically with the VB side of things,, um maybe i should look in to having a debugger myself? what would be good to get?
maybe I should start a new thread for the pic code since there have been several changes(or just put it here)...?
also, im not even sure if that is the right usart pin, I just took the remaining pins avail, plus im not comfortable with crystals yet, but USART was working fine for me, until recently,
in mplab? i got pickit2 programmer
but mplab isK2Error0028: Unable to enter debug mode
it checks out, enters debug, asks to reprogram(yes), asks to turn off watchdog(yes), asks to turn off lvp(yes),
PK2Error0024: unable to establish vdd on target... 0v
??????????????
mplab is powering the circuits but not after i reprogram it to go in to debug??
Programming Target (1/3/2012 5:39:21 PM)
PIC18F4620 found (Rev 0x7)
Erasing Target
Programming Debug Executive (0x-FDC0 - 0xFFFF)
Verifying Debug Executive (0xFDC0 - 0xFFFF)
Programming Debug Vector
Verifying Debug Vector
Programming Configuration Memory
Verifying Configuration Memory
PK2Error0028: Unable to enter debug mode
PICkit 2 Ready
also is there a way to watch the variables as they change in debug?
void main(void){
//your code here.
while(1);
}
You can also use:
LATAbits.LATA0 = 1; to set a bit, or:
PORTAbits.RA0; to read a bit.
variable = _RB5; // Reads PortB, 5.
_LATB5 = x; // Sets PortB, 5.
_TRISB5 = x; // Sets TrisB, 5.
_ADON = 1; // Sets the ADCON1.ADON bit.
_T1CKPS = 3; // Sets the prescaler for Timer1
well now thats handy stuff(all you guys!) epically with the variables. and this conversion is going quite fast with that replace box!, however I seem to have stumbled upon a minor bump, im not sure if im declaring/setting up my functions proper, but compiler is saying error on line 172 (at the bottom of the page), im sure it something simple im missing, also could we just check if my "if" statements are ok(a few before line 172), i think i seen it somewhere like that?
also c book is saying that c variables are all short or long, does that mean to get i bit i break it up like the ports, and bytes?
oh an also all those int's at the beginning, do i need to "DIM" bytes,arrays?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?