mr.sneezy
- 29th May 2010, 13:08
My kicked Black Cat is back...
I ported my BMP085 test code from a 18F1220 to a 18F4620, and after reconfiguring the config directives, and checking port pins correct etc etc I expected my code to run. Well it did, except I can not get SEROUT2 to work on the 18F4620.
It's like the PBP SEROUT2 command is broken for this PIC.
I've changed pins three times now, and my 'I'm Alive' LED will flash away perfectly normally on it's own pin OR on the pin that I tried out SEROUT2 on (I swapped the SEROUT pin and LED pin in my code). So the pin is fine because it can drive a LED, but I get no serial data out of it when used for SEROUT2 instead. Weird hey.
Anybody know if there are any bugs with the 18F4620 and SEROUT2 ?
I'd have thought not, but before a spend a day trying to work out why, I thought I'd ask here to save my small amount of remaining sanity.
I also checked my OSC clock speed by measuring 500mS LED pulses on my CRO, yep it's spot on time. I also put a 18F1220 back on my test board, and yes SEROUT2 to my serial LCD works fine, so my Serial LCD is still OK.
I need a few Panadols and a lay down,
Martin
The first part of my code up to just after the first SEROUT2's in included below.
'Config Directive settings for MPASM (fuses) for 18F4620
@ __CONFIG _CONFIG1H, _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_INTIO7_1H
@ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_32_2H
@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVREN_OFF_4L
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H
DEFINE OSC 8 '8Mhz clock used.
' Define some constants if needed
' Software Defines (variables and pins)
Cal_table var word[11] '11 word array to store calibration data
lUpres var long 'Long variable for Uncompensated Pressure
lPres var Long 'Long variable for Compensated Pressure
lTemp_Var1 Var long 'Long temporary variable
X1 var Long
X2 var Long
X3 var Long
B3 var long
B4 var long
B5 var long
B6 var Long
B7 var long
lAC1 var Long 'Long variables for cal values actually negative in my sensor
lAC2 var long
lAC3 var Long
lAC4 var Long
lMB var Long
lMC var Long
bTemp_Var1 var byte 'Byte temp variable
wTemp_Var1 var Word 'Word temp variable
wTemp_Var2 var word 'Word temp variable
lUTemp var long 'Uncompensated temp reading
lCTemp var Long 'Compensated temperature x10 (1/10th of C)
' UTemp var word 'Uncompensated temp reading
' UPres var word 'uncompensated pressure reading
i2c_Reg var Byte 'variable for target i2c register address
CPIN var PortB.0 ' I2C clock pin
DPIN var PortB.1 ' I2C data pin
SO Var PortD.0 'Serial out pin
LED var PortA.1 'Indicator LED, via 500ohm to +3.3V
'Alias's for calibration data in the sensor to match the Bosch parameter list names
AC1 var Cal_table[0] '
AC2 var Cal_table[1] 'BMP085 has 11 16bit values stored in EEPROM
AC3 var Cal_table[2] 'First byte is at $AA last at $BF, two bytes per cal value
AC4 var Cal_table[3] 'Lowbyte is MSB (e.g $AA), Highbyte is LSB (e.g. $AB)
AC5 var Cal_table[4] 'some values are signed (not AC4, AC5, AC6)
AC6 var Cal_table[5]
B1 var Cal_table[6]
B2 var Cal_table[7]
MB var Cal_table[8]
MC var Cal_table[9]
MD var Cal_table[10]
' Initialise Processor - check for each PIC type
' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ADCON1 = %00001111 'Turn off all AD's
' OSCCON = %01100111 'set INTRC to 4 MHZ
OSCCON = %01110111 'set INTRC to 8 MHZ
' OSCTUNE = 0 'OSC trim set to Null
' Include "modedefs.bas" ' Include serial modes
' Set initial state of port pins as Input or Output
TRISA = %11111100 'Input(0 = output, 1 = Input)
TRISB = %11111100 '
TRISC = %11111111
TRISD = %11111111
TRISE = %11111111
' PIC initialization code
Low So 'Must start low, or you get rubbish on the LCD at PIC boot up.
Low LED 'LED on
pause 500 'led on for x seconds
High LED 'LED off
Pause 500
Low LED 'LED on
pause 500 'led on for x seconds
High LED 'LED off
Serout2 SO,16780,[$FE,$01] ' Clear LCD & home LCD cursor.
pause 10 ' wait for LCD to catch up
Serout2 SO,16780,[" FrSky Vario "] ' Serial print
Serout2 SO,16780,[$FE,$C0] ' Shift cursor to line2
Serout2 SO,16780,[" Development Jig "] ' Serial print
Pause 5000 'wait three seconds
I ported my BMP085 test code from a 18F1220 to a 18F4620, and after reconfiguring the config directives, and checking port pins correct etc etc I expected my code to run. Well it did, except I can not get SEROUT2 to work on the 18F4620.
It's like the PBP SEROUT2 command is broken for this PIC.
I've changed pins three times now, and my 'I'm Alive' LED will flash away perfectly normally on it's own pin OR on the pin that I tried out SEROUT2 on (I swapped the SEROUT pin and LED pin in my code). So the pin is fine because it can drive a LED, but I get no serial data out of it when used for SEROUT2 instead. Weird hey.
Anybody know if there are any bugs with the 18F4620 and SEROUT2 ?
I'd have thought not, but before a spend a day trying to work out why, I thought I'd ask here to save my small amount of remaining sanity.
I also checked my OSC clock speed by measuring 500mS LED pulses on my CRO, yep it's spot on time. I also put a 18F1220 back on my test board, and yes SEROUT2 to my serial LCD works fine, so my Serial LCD is still OK.
I need a few Panadols and a lay down,
Martin
The first part of my code up to just after the first SEROUT2's in included below.
'Config Directive settings for MPASM (fuses) for 18F4620
@ __CONFIG _CONFIG1H, _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_INTIO7_1H
@ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_32_2H
@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVREN_OFF_4L
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H
DEFINE OSC 8 '8Mhz clock used.
' Define some constants if needed
' Software Defines (variables and pins)
Cal_table var word[11] '11 word array to store calibration data
lUpres var long 'Long variable for Uncompensated Pressure
lPres var Long 'Long variable for Compensated Pressure
lTemp_Var1 Var long 'Long temporary variable
X1 var Long
X2 var Long
X3 var Long
B3 var long
B4 var long
B5 var long
B6 var Long
B7 var long
lAC1 var Long 'Long variables for cal values actually negative in my sensor
lAC2 var long
lAC3 var Long
lAC4 var Long
lMB var Long
lMC var Long
bTemp_Var1 var byte 'Byte temp variable
wTemp_Var1 var Word 'Word temp variable
wTemp_Var2 var word 'Word temp variable
lUTemp var long 'Uncompensated temp reading
lCTemp var Long 'Compensated temperature x10 (1/10th of C)
' UTemp var word 'Uncompensated temp reading
' UPres var word 'uncompensated pressure reading
i2c_Reg var Byte 'variable for target i2c register address
CPIN var PortB.0 ' I2C clock pin
DPIN var PortB.1 ' I2C data pin
SO Var PortD.0 'Serial out pin
LED var PortA.1 'Indicator LED, via 500ohm to +3.3V
'Alias's for calibration data in the sensor to match the Bosch parameter list names
AC1 var Cal_table[0] '
AC2 var Cal_table[1] 'BMP085 has 11 16bit values stored in EEPROM
AC3 var Cal_table[2] 'First byte is at $AA last at $BF, two bytes per cal value
AC4 var Cal_table[3] 'Lowbyte is MSB (e.g $AA), Highbyte is LSB (e.g. $AB)
AC5 var Cal_table[4] 'some values are signed (not AC4, AC5, AC6)
AC6 var Cal_table[5]
B1 var Cal_table[6]
B2 var Cal_table[7]
MB var Cal_table[8]
MC var Cal_table[9]
MD var Cal_table[10]
' Initialise Processor - check for each PIC type
' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ADCON1 = %00001111 'Turn off all AD's
' OSCCON = %01100111 'set INTRC to 4 MHZ
OSCCON = %01110111 'set INTRC to 8 MHZ
' OSCTUNE = 0 'OSC trim set to Null
' Include "modedefs.bas" ' Include serial modes
' Set initial state of port pins as Input or Output
TRISA = %11111100 'Input(0 = output, 1 = Input)
TRISB = %11111100 '
TRISC = %11111111
TRISD = %11111111
TRISE = %11111111
' PIC initialization code
Low So 'Must start low, or you get rubbish on the LCD at PIC boot up.
Low LED 'LED on
pause 500 'led on for x seconds
High LED 'LED off
Pause 500
Low LED 'LED on
pause 500 'led on for x seconds
High LED 'LED off
Serout2 SO,16780,[$FE,$01] ' Clear LCD & home LCD cursor.
pause 10 ' wait for LCD to catch up
Serout2 SO,16780,[" FrSky Vario "] ' Serial print
Serout2 SO,16780,[$FE,$C0] ' Shift cursor to line2
Serout2 SO,16780,[" Development Jig "] ' Serial print
Pause 5000 'wait three seconds