Jump to content

Recommended Posts

Guys, I am sure this is real "page 1" stuff! I am a complete C newbie, having cut my teeth more moons ago than I care to remember on FORTRAN (yes, I am THAT old) and Borland Pascal. I have also written a number of PIC programs in assembler. Fast, tight code, I get exactly what I want, but by golly does it take a long to time get it right! For my next project, I've decide to make the leap to C, and BoostC in particular.

 

It's printf() that's got me stumped. I can see how the command works, just not where it comes out! My application may have an output device, but it sure wont be standard, and I will address it by sending bytes directly to the ports. But if I set up a simple level-shifter, and build a PIC>RS232 interface from the built in UART, can I printf() to that and so to my PC screen?

 

I am trying to learn the basics of C on my PC first, using a public domain C compiler. Once I've got the hang of that, I'll move "down" to my PIC

 

Thanks all

 

Laurence Wilkins

www.MrNixie.com - see what I mean about the "non-standard output device? ;) )

Link to post
Share on other sites
I am trying to learn the basics of C on my PC first, using a public domain C compiler. Once I've got the hang of that, I'll move "down" to my PIC

 

Laurence Wilkins

www.MrNixie.com - see what I mean about the "non-standard output device? ;) )

 

Hi Laurence,

 

 

For a quick start try this thread.."PIC micro programming in BoostC for beginners"

 

As far as printf command is concerned you have lprintf used only with LCD. See page 78 of BoostC manual. for serial communication you can use serial_printf command available in the folder named lika.be( i don't know if it comes with the source boost ide down load or whether i down loaded it from his website)lika.be

 

Regards

 

Raghunathan.

Link to post
Share on other sites

Raghunathan, thanks for your reply. The penny begins to drop! My next question was going to be "what is the LCD wiring?", but reading through LCD.H I think I can see what's going on. I'll start with an LCD interface first, then see if i can get a serial one running later.

 

I'm going to have to be careful though, as my software is pretty time-critical, and it can't spend a lot of time "hanging about" waiting for serial data to be output! Most of my current assembly routines use interrupts. Once I get really clever, I guess I could build an interupt driven serial output. Best to learn to crawl before I fly, though! ;)

 

And yes! I will start with the tutorial you mentioned. Thanks again for your kind help

 

Laurence

 

I am trying to learn the basics of C on my PC first, using a public domain C compiler. Once I've got the hang of that, I'll move "down" to my PIC

 

Laurence Wilkins

www.MrNixie.com - see what I mean about the "non-standard output device? :P )

 

Hi Laurence,

 

 

For a quick start try this thread.."PIC micro programming in BoostC for beginners"

 

As far as printf command is concerned you have lprintf used only with LCD. See page 78 of BoostC manual. for serial communication you can use serial_printf command available in the folder named lika.be( i don't know if it comes with the source boost ide down load or whether i down loaded it from his website)lika.be

 

Regards

 

Raghunathan.

Link to post
Share on other sites

I am new to C & PIC's myself and am not qualified to answer anything with any authority but if I understand

your question correctly this may help.

 

I can see how the command works, just not where it comes out!

You can write you own Print function that is hardware specific for your needs. I used the following to send

text via a hardware serial port on a 16F887.

 

void PRINT(char str_Text[])
{
j=0;
while(str_Text[j] != 0)
   {
	txreg = str_Text[j];				  // Load serial out register with data
	j++;
	while(!pir1.4);						 // Wait until serial out register is clear
   }
}

void main(void)
{
	while(1)
	  {
		   if (some criteria)
				PRINT("Hello Everybody");
	  }
}

 

With this print function and a level shifter you should be able to send data to your PC.

Hope this helps.

 

Matt Christisen

Link to post
Share on other sites
The penny begins to drop! My next question was going to be "what is the LCD wiring?", but reading through LCD.H I think I can see what's going on. I'll start with an LCD interface first, then see if i can get a serial one running later.

 

Give a couple of days time & i will post a example program with circuit schematics in my thread.

 

Regards

Raghunathan

Link to post
Share on other sites

Laurence,

 

Take a look at sprintf (documented in the BoostC manual), it does output formatting and stores the result in a character string.

 

Regards

Dave

Link to post
Share on other sites

Hi Dave, it's not so much the formatting of output that had me stumped, but more where the output comes out by default! Followinf on from the above replies and some more digging, I begin to see the light. I will try a vanilla flavoured LCD interface and see if I can get it to display "hello world"

 

Thanks for your response anyway

Link to post
Share on other sites
I will try a vanilla flavoured LCD interface and see if I can get it to display "hello world"

 

You disapoint me , Id rather you print "07734" on some inverted Nixie tubes.

 

Hey Picxie, I geddit!! :rolleyes: for the sake of a good joke, I shall of course let it pass that "normal" nixie tubes are not seven segment devices.

 

I am currently writing the application software for these nixie clocks in assembler. But I thought it time to move up a gear, so to speak. I ultimately probably wont need a printf() command at all, as I will still speak to the nixie tubes via direct port control. But I needed a half-way house, so that I could "see" if my early code was doing what I had intended it do.... Having said that, I am beginning to realise the power of a language such as C, where you can write your own high level instructions, and then call them as if they were any other C command. Maybe I should be thinking about print_nixie() ?? :angry:

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...