DEFINE OSC 16 should work with your config settings. If you're trying to use the MCS+ ICD, make sure you compile with the ICD/Compile button. If you're just trying to verify the connection with HSEROUT, then use the normal Compile button.
DEFINE OSC 16 should work with your config settings. If you're trying to use the MCS+ ICD, make sure you compile with the ICD/Compile button. If you're just trying to verify the connection with HSEROUT, then use the normal Compile button.
I tried both 48 and 16 MHz defines and also made sure the recompiles were with just the Compile button and not the Compile/ICD button.
I also generated a simpler program to test the serial inteerface that just reads the HSERIN from the PC host and then resends the same received character to the PC host with HSEROUT (see included code below). The PC host hyperterminal says the sends are going out, but never receive back any resends from the PIC. I also included in the HSERIN statement a timeout to a label that blinks LEDs as an error if timeout occurs. It does, so it confirms that the serial interface is not working and is timing out.
Almost seems like a hardware failure on the EasyPic6 side, but I don't want to RMA the EasyPic6 all the way back to Rumania to have them check/repair the unit due to the time delays and the cost....the EasyPic6 is my development board....just wish I could get the serial interface to it working so I could then use the MCSPlus ICD debugger with it.
At this point I am really baffled. Any other suggestions as to how I can verify the serial interface?
Code:' -----------------------[ Program Description ]-------------------------- ' Program is for a PIC18F2550/4550 & was tested in an EasyPic6 board. ' PICBASIC PRO program to send and receive from the hardware serial port ' LEDs count characters and flash error if none received for 10 seconds ' ' -------------[ Revision History ]-------------------------------------- ' Version 1.0 Started on 03/04/2012 '--------------[ Define EEPROM usage ]----------------------------------- ' -----[ Device Declaration ]--------------------------------------------- ;--- if you un-comment these, you must comment the ones in the .inc file-- ASM ; 18F2550/4550, 8mhz crystal __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L ENDASM Include "Modedefs.Bas" INCLUDE "ALLDIGITAL.pbp" ' Sets all registers for digital ops. ' User must make sure the AllDigital.pbp file ' is in same directory location as this source ' code before compiling. 'DEFINE SHOWDIGITAL 1 ' When uncommented will show analog settings ' in Assembler Results window DEFINE OSC 16 DEFINE I2C_SLOW 1 ' Set i2c to the standard speed DEFINE I2C_HOLD 1 ' Enable recieving i2c device to pause communication '--------------[ Declare Variables, Aliases & Constants ]--------------- ' Variables & Aliases for Pins ' =============================================== char Var Byte ' Storage for serial character cnt Var Byte ' Storage for character counter ' Constants '========== ' Initialize Hardware ' =================== 'Set registers TRISB = %11001111 ' Set PORTB.4,5 to outputs PORTB = 0 ' Turn off LEDs cnt = 0 ' Zero character counter ' Setup Hardware for uart ' ======================= 'DEFINE HSER_BAUD 9600 'DEFINE HSER_RCSTA 90h 'DEFINE HSER_TXSTA 24h 'DEFINE HSER_CLROERR 1 ' * NOTES for use with EasyPic6 development board: ' Set SW7.1 on for RC7 = RX and SW8.1 on for RC6 - TX 'For use with COG 2x16 LCD: ' - Turn on Port Expander switches SW6.1,SW6.2,SW6.3,SW6.4 & SW6.5. ' - Turn on COG LCD 2x16 switches SW10.1,SW10.2,SW10.3,SW10.4,SW10.5 ' and SW10.6. ' Set EUSART configuration for serial interface to EasyPic6 ' For MCSPlus ICD debugging only....comment out for operations 'TRISC.6 = 1 'TRISC.7 = 1 'RCSTA.7 = 1 '--------------------[ Begin Main Program Loop ]------------------------ mainloop: PAUSE 100 ' Without this PAUSE, there's nothing to keep the Watch Dog ' Timer clear. LOW & GOTO don't generate CLRWDT instructions. ' See www.picbasic.co.uk/forum/showthread.php?p=84722#post84722 Hserin 10000, allon, [char] ' Get a char from serial port..if timeout go ' to label as error Hserout [char] ' Send char out serial port cnt = cnt + 1 ' Increment character count PORTB = cnt << 4 ' Send count to LED Goto mainloop ' Do it all over again allon: PORTB = %00110000 ' Error - no character received Pause 500 ' Blink all LEDs PORTB = 0 Pause 500 Goto allon End ' Safety measure to insure program stops if reaches here
Below are the setting for 9600 baud at 16MHz
You have the ones in your code commented out.Code:RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $20 ' Enable transmit, BRGH = 0 SPBRG = 25 ' 9600 Baud @ 0.16%
Run this code and type numbers at the keyboard.
Code:ASM ; 18F2550/4550, 8mhz crystal __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L ENDASM DEFINE OSC 16 ADCON1 = 15 ' All I/O pins digital X VAR BYTE START: RCSTA.4 = 0 : RCSTA.4 = 1 RCSTA=$90:TXSTA=$20:SPBRG=25 HSERIN [DEC X] HSEROUT [DEC X,$d,$a] GOTO START
Dave
Always wear safety glasses while programming.
On SW7 & SW8 flip everything else to the OFF position leaving only switches #8 on each one ON. Does it work?Set SW7.1 on for RC7 = RX and SW8.1 on for RC6 - TX
In: http://www.mikroe.com/pdf/easypic6/e...anual_v100.pdf the photo in Figure 6-1 shows both DIP
switches for RC6 & RC7 on switch positions #1.
And just below this in Figure 6-2 they show RC6 & RC7 on DIP switch positions #8. Which is right?
Last edited by Bruce; - 5th March 2010 at 04:31. Reason: Which is right?
Tried it both ways, Bruce, while running Mackrackit's code as I modified it above. And as I said in above post to him, no LED test lights turned on, indicating the HSERIN and HSEROUT statements never executed....meaning no receipt of the character I typed on the keboard by the HSERIN.
Any other ideas?
I always include DEFINE HSER_CLROERR 1 if using HSERIN just to be sure it' never locked up on me, but I'm not sure that's the problem.
Try sending first. Something like HSEROUT ["Hello World",13,10] to MCS terminal. If this doesn't work, then try using SEROUT2 PORTC.6,84,["Hello World",13,10].
If you get nothing on screen, I would check my connection from RC6 to the PC side of the MAX IC, serial cable, etc.
If you have an O-Scope set it in a continuous HSEROUT loop while watching the MAX TX out pin to PC.
I will try those ideas, Bruce.
Got to wondering if the MCU was actually running. I can see from the PRG light on the EasyPic6 it is getting programmed but in previous code didn't have any way to confirm it was actually running....if it weren't that could explain why the test LEDs didn't light in previous post and also possibly why the HSERIN and HSEROUT statement aren't executing...hence no communications.
I inserted a blinking LED in the loop in the below version and when I run it, it doesn't blink...indicating the MCU is not running!! Now I don't know what to do to make the MCU run.?????
Code:ASM ; 18F2550/4550, 8mhz crystal __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L ENDASM Include "Modedefs.Bas" INCLUDE "ALLDIGITAL.pbp" ' Sets all registers for digital ops. ' User must make sure the AllDigital.pbp file ' is in same directory location as this source ' code before compiling. DEFINE OSC 16 TRISB = %00001111 ' Set PORTB.4,5,6,7 to outputs as test LEDs ADCON1 = 15 ' All I/O pins digital PORTB.5 = 0 PORTB.6 = 0 ' Turn off the LEDs PORTB.7 = 0 X VAR BYTE START: PORTB.5 = 1 ' Blink LED as test that MCU is running RCSTA.4 = 0 : RCSTA.4 = 1 RCSTA=$90:TXSTA=$20:SPBRG=25 HSERIN [DEC X] PORTB.6 = 1 ' Turn on PortB.6 LED if this statement is executed ' as test of receiving a character HSEROUT [DEC X,$d,$a] PORTB.7 =1 ' Turn on PortB.7 LED if this statement is executed ' as test of HSEROUT having sent a character PORTB.5 = 0 GOTO START
Mackrackit, I created a .pbp file from your above code with a slight modification where I inserted a LED turn on just after the HSERIN and just after the HSEROUT statements. See the code below. Then when running the code and typing characters on the keyboard I do not see these respective lights come on in the EasyPic6. This says the HSERIN and the HSEROUT statements are never executing when the code is running and the PC terminal is connected. This implies a hardware failure somwhere in the EasyPic6 serial interface circuitry....do you agree???
Code:ASM ; 18F2550/4550, 8mhz crystal __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L ENDASM DEFINE OSC 16 TRISB = %00001111 ' Set PORTB.4,5,6,7 to outputs as test LEDs ADCON1 = 15 ' All I/O pins digital PORTB.6 = 0 ' Turn off the LEDs PORTB.7 = 0 X VAR BYTE START: RCSTA.4 = 0 : RCSTA.4 = 1 RCSTA=$90:TXSTA=$20:SPBRG=25 HSERIN [DEC X] PORTB.6 = 1 ' Turn on PortB.6 LED if this statement is executed ' as test of receiving a character HSEROUT [DEC X,$d,$a] PORTB.7 =1 ' Turn on PortB.7 LED if this statement is executed ' as test of HSEROUT having sent a character GOTO START
Last edited by jellis00; - 5th March 2010 at 05:16. Reason: Add the code
Bookmarks