Jump to content


Tom

Member Since 11 Nov 2014
Offline Last Active Nov 13 2014 06:49 PM
-----

Topics I've Started

18f4550 serial interface with VB

11 November 2014 - 04:30 AM

Hello.

 

I have a project I need some help with, I newish to microcontrollers and the C language. I'm ok with VB and electronics. I've got some simple stand-alones to work so far after much tinkering.

 

I wrote a very simple program in VB to communicate with the microcontroller via serial (UART) cp201 (where I'm totally stuck) just to turn on a few leds and then turn them all off. The VB code is working along with the UART converter. It will TX when I click on a button in my VB program. 9600 baud, 8 bit, 1 stop no parody.

 

I have the data sheet for the pic and still do not know the proper code to communicate with the pic18F4550. 

 

I'm attaching my attempt at the pic code which I did get to compile but does not "work" when downloaded into the pic.  I left some older code in that I got from the data sheet (maybe still relevant) but commented out.

I think someone experienced in it could see the issues with the code immediately.

BTW I used MPLABX and xc8 compiler. (still learning how to use)

I am using the internal oscillator at 8 MHz (not sure if this is compatible with the UART communication) according to the data sheet  OSCCON should be set to 51 but my other simple stand alones use 0x76 (hex)

A simple working example will help out tremendously.

 

Any help feedback is appreciated.

TomAttached File  18f4550 UART interface.rtf   3.01KB   4 downloads