View previous topic :: View next topic |
Author |
Message |
cootemca
Joined: 30 Jul 2014 Posts: 2
|
PIC18F4550 sending data to the PC |
Posted: Wed Jul 30, 2014 8:55 pm |
|
|
Good evening, my question is, how to make a program sending data from PIC18F4550 to a PC. Please show me an example. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 30, 2014 10:36 pm |
|
|
Code: |
#include <18F4550.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//====================================
void main()
{
printf("Hello World\n\r");
while(1);
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Thu Jul 31, 2014 1:16 am |
|
|
I suspect he might be wanting to use USB (since he is using the 4550). So perhaps ex_usb_serial.c |
|
|
cootemca
Joined: 30 Jul 2014 Posts: 2
|
Send data from PIC to PC with PIC18F4550 |
Posted: Thu Jul 31, 2014 8:55 pm |
|
|
You're absolutely right, the idea is to use usb_put_packet() and send data
byte by byte. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Fri Aug 01, 2014 12:57 am |
|
|
You don't need to fiddle with put_packet. As I said, look at ex_usb_serial (and the other versions). These generate a CDC device, and send the data byte by byte, but buffer this through usb_putc/getc, so you can simply printf a message and it is all sent for you. |
|
|
|