G genkiyan New Member Sep 7, 2005 #1 how to program the tris and status bit of pic 16f877? by using c language. thanx!!
Nigel Goodwin Super Moderator Most Helpful Member Sep 7, 2005 #2 genkiyan said: how to program the tris and status bit of pic 16f877? by using c language. thanx!! Click to expand... You don't program the STATUS word, it's controlled by the PIC itself, you merely check the bits to see results. Can't help you on C, but presumably the compiler comes with a helpfile and examples?, just look at those!.
genkiyan said: how to program the tris and status bit of pic 16f877? by using c language. thanx!! Click to expand... You don't program the STATUS word, it's controlled by the PIC itself, you merely check the bits to see results. Can't help you on C, but presumably the compiler comes with a helpfile and examples?, just look at those!.
Joel Rainville New Member Sep 7, 2005 #3 genkiyan said: how to program the tris and status bit of pic 16f877? by using c language. thanx!! Click to expand... https://www.microchipc.com/HiTechCFAQ/#_Toc475127498 You probably want to bookmark that website if you're gonna use C a lot on the PIC.
genkiyan said: how to program the tris and status bit of pic 16f877? by using c language. thanx!! Click to expand... https://www.microchipc.com/HiTechCFAQ/#_Toc475127498 You probably want to bookmark that website if you're gonna use C a lot on the PIC.
Joel Rainville New Member Sep 7, 2005 #5 Jay.slovak said: Try TRISA = 255; :lol: Click to expand... Hey, not bad Jay, not bad... You've been reading datasheets, don't you? We can tell!... :lol:
Jay.slovak said: Try TRISA = 255; :lol: Click to expand... Hey, not bad Jay, not bad... You've been reading datasheets, don't you? We can tell!... :lol:
J Jay.slovak Active Member Sep 8, 2005 #6 Joel Rainville said: Jay.slovak said: Try TRISA = 255; :lol: Click to expand... Hey, not bad Jay, not bad... You've been reading datasheets, don't you? We can tell!... :lol: Click to expand... Yep, as always 8) But I wrote this because I am also learning C language - C18~C30 (by my self), and I still find Assembly easyer to program and understand (not including C's HW resources).
Joel Rainville said: Jay.slovak said: Try TRISA = 255; :lol: Click to expand... Hey, not bad Jay, not bad... You've been reading datasheets, don't you? We can tell!... :lol: Click to expand... Yep, as always 8) But I wrote this because I am also learning C language - C18~C30 (by my self), and I still find Assembly easyer to program and understand (not including C's HW resources).
J Jay.slovak Active Member Sep 8, 2005 #7 And in case you neet to bit-bang the TRIS register, I believe this should work Code: TRISBbits.TRISB7=1;
And in case you neet to bit-bang the TRIS register, I believe this should work Code: TRISBbits.TRISB7=1;
Exo Active Member Sep 8, 2005 #8 Jay.slovak said: And in case you neet to bit-bang the TRIS register, I believe this should work Code: TRISBbits.TRISB7=1; Click to expand... That's in C18, since he's using a 16F877 he is using a 3rd party compiler wich may use completely diffirent names. Some even dont allow bit manipulation this way and only allow it by AND'ing and OR'ing the byte...
Jay.slovak said: And in case you neet to bit-bang the TRIS register, I believe this should work Code: TRISBbits.TRISB7=1; Click to expand... That's in C18, since he's using a 16F877 he is using a 3rd party compiler wich may use completely diffirent names. Some even dont allow bit manipulation this way and only allow it by AND'ing and OR'ing the byte...
J Jay.slovak Active Member Sep 8, 2005 #9 Exo said: Jay.slovak said: And in case you neet to bit-bang the TRIS register, I believe this should work Code: TRISBbits.TRISB7=1; Click to expand... That's in C18, since he's using a 16F877 he is using a 3rd party compiler wich may use completely diffirent names. Some even dont allow bit manipulation this way and only allow it by AND'ing and OR'ing the byte... Click to expand... Hmm that sucks, I prefer to use Microchips toolsuits...
Exo said: Jay.slovak said: And in case you neet to bit-bang the TRIS register, I believe this should work Code: TRISBbits.TRISB7=1; Click to expand... That's in C18, since he's using a 16F877 he is using a 3rd party compiler wich may use completely diffirent names. Some even dont allow bit manipulation this way and only allow it by AND'ing and OR'ing the byte... Click to expand... Hmm that sucks, I prefer to use Microchips toolsuits...
Joel Rainville New Member Sep 8, 2005 #10 Exo said: That's in C18, since he's using a 16F877 he is using a 3rd party compiler wich may use completely diffirent names. Click to expand... I never realized Microchip did not have a C compiler for the PIC16... :shock: Sure enough, all the C sample code for the PIC16 on microchipc.com is for the Hi Tech compiler : https://www.microchipc.com/HiTechCFAQ/#_Toc475127498 It looks like bit banging is done the same way as C18 (based on what Jay posted at least), but uses a whole different syntax.
Exo said: That's in C18, since he's using a 16F877 he is using a 3rd party compiler wich may use completely diffirent names. Click to expand... I never realized Microchip did not have a C compiler for the PIC16... :shock: Sure enough, all the C sample code for the PIC16 on microchipc.com is for the Hi Tech compiler : https://www.microchipc.com/HiTechCFAQ/#_Toc475127498 It looks like bit banging is done the same way as C18 (based on what Jay posted at least), but uses a whole different syntax.
J Jay.slovak Active Member Sep 8, 2005 #11 Personally I hate how to bit-bang in C18, I would prefer something like: Code: TRISB7=true or TRISB.7=false
Personally I hate how to bit-bang in C18, I would prefer something like: Code: TRISB7=true or TRISB.7=false
Joel Rainville New Member Sep 8, 2005 #12 It's done like this with the Hi Tech compiler : Code: RA0=1; //produce 5V on RA0, pin 2 of micro RA0=0; //produce 0V on RA0, pin 2 of micro Pretty straightforward...
It's done like this with the Hi Tech compiler : Code: RA0=1; //produce 5V on RA0, pin 2 of micro RA0=0; //produce 0V on RA0, pin 2 of micro Pretty straightforward...
J Jay.slovak Active Member Sep 8, 2005 #13 Joel Rainville said: It's done like this with the Hi Tech compiler : Code: RA0=1; //produce 5V on RA0, pin 2 of micro RA0=0; //produce 0V on RA0, pin 2 of micro Pretty straightforward... Click to expand... Hmm, that's much better than C18 :?
Joel Rainville said: It's done like this with the Hi Tech compiler : Code: RA0=1; //produce 5V on RA0, pin 2 of micro RA0=0; //produce 0V on RA0, pin 2 of micro Pretty straightforward... Click to expand... Hmm, that's much better than C18 :?
Exo Active Member Sep 8, 2005 #14 No it isnt. Using a name for every bit causes massive namespace pollution. C18's way is much cleaner, by grouping the bits in a bitfield struct... I agree the names are a bit long though...
No it isnt. Using a name for every bit causes massive namespace pollution. C18's way is much cleaner, by grouping the bits in a bitfield struct... I agree the names are a bit long though...
J Jay.slovak Active Member Sep 8, 2005 #15 Exo said: No it isnt. Using a name for every bit causes massive namespace pollution. C18's way is much cleaner, by grouping the bits in a bitfield struct... I agree the names are a bit long though... Click to expand... That's true, but it's much harder o do it C18 way (especially for beginner).
Exo said: No it isnt. Using a name for every bit causes massive namespace pollution. C18's way is much cleaner, by grouping the bits in a bitfield struct... I agree the names are a bit long though... Click to expand... That's true, but it's much harder o do it C18 way (especially for beginner).