Does your hardware have an inverter like a MAX232?
Does your hardware have an inverter like a MAX232?
OK I got it to work , not sure why but I had to change OSC fuse to ECIO and not ECPIO, so even though im useing a ttl OSC I cant use RA6
heres the code that works, note fuse is set to ECIO(NO USB) and PLL is set to 20Mhz
NOTE: TXSTA = $20 ' must be 20, 24 doesnt work, even though online articles said so.Code:Define OSC 20 define HSER_BAUD 9600 DEFINE HSER_BITS 8 DEFINE HSER_CLROERR 1 RCSTA = $90 TXSTA = $20 TRISC = %10000000 TRISD = 0 start: Hserout ["Hello World", 13, 10] pause 1000 goto start End
Chris
Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."
Chris, the define statements are shortcuts built into PBP that do several things, including setting RXSTA and TXSTA properly for the BAUD you have chosen - and other registers. You can set ALL the registers manually, OR you use the define statements, but don't do both. When you set them manually in the next two statements after having just DEFINEd them, you are potentially changing those registers to an incorrect value, for instance the wrong value of 24. If you actually read the datasheet, you will see when 24 is correct and when 20 is correct. Likely the information in "online articles" was taken out of context. It is possible to make either value work for some baud rates, but to do so you need the correct values in other registers, like it says in the datasheet.
If you are starting to hear a recurring piece of advice in my comments, you are getting the message. One last time... read the datasheet. The device datasheet tells you how to set all the registers, the PBP manual tells you what the defines actually do.
Bookmarks