In SX Microcontrollers, SX/B Compiler and SX-Key Tool, tdg8934 wrote: I tried inserting a PAUSE 50 between each LOW and HIGH control signal and still no output on the LEDs. I need some help perhaps by Parallax or Bean maybe to see what is so different in the timing between the SX-28 and the BS2. I have tried everything under the sun and the SX-28 program still shows no output LED's unlike the BS2 version which is running fine with no extra PAUSE statements needed. Perhaps since it is the work week now, I can get some more help with a different perspective. [code] ' ========================================================================= ' ' File...... 8255_Test.SXB ' Purpose... SX/B interface to 8255 ' Author.... Timothy Gilmore ' E-mail.... [url=gilmoret@us.saic.com]gilmoret@us.saic.com[/url] ' Started... 21 OCT 2006 ' Updated... 22 OCT 2006 ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' BS2 conversion program to SX-28 interface with an 8255 ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX 'Use no external resonator FREQ 4_000_000 ID "SXB 1.50" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- Reset_8255 PIN RB.0 OUTPUT WR_8255 PIN RB.1 OUTPUT A0_8255 PIN RB.2 OUTPUT A1_8255 PIN RB.3 OUTPUT CS1_8255 PIN RB.4 OUTPUT RB_OUT PIN RB OUTPUT RC_OUT PIN RC OUTPUT ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- pattern1 VAR Byte pattern2 VAR Byte pattern3 VAR Byte ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- Initialize_8255 SUB PortA_8255 SUB PortB_8255 SUB PortC_8255 SUB ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: ' initialization code here RB_OUT = $00 'RB pins are set LOW (Control lines Active Low) RC_OUT = $00 'RC pins are set LOW Initialize_8255 Main: ' main code here pattern1 = %10101010 'Set patterns for the 8255 Output Ports (Read it in reverse) pattern2 = %11110000 pattern3 = %00110011 PortA_8255 'GOSUB to the Portx_8255 routines 'PortB_8255 'PortC_8255 GOTO Main ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- Initialize_8255: 'Initialize 8255 to All Outputs at Active Low state RB_OUT = $FF 'RB pins (Control lines are set Inactive HIGH) PAUSE 50 'Settling time for a few ms (50 ms) LOW Reset_8255 '8255 is Reset (Active) PAUSE 50 HIGH WR_8255 'Set Write control High (Inactive) PAUSE 50 HIGH A1_8255 'Set Address control A1 & A0 High to access the control word register PAUSE 50 HIGH A0_8255 PAUSE 50 RC_OUT = $80 'Set databus (D0-D1 of 8255) to $80 for MODE 0 - All 3 8255 ports as outputs LOW CS1_8255 'Set Chip Select Low (Active) PAUSE 50 PULSOUT WR_8255, 10 'Pulse Write control Low (Active) for 100 us (duration not critical) PAUSE 50 HIGH CS1_8255 'Set Chip Select High (Inactive) - All 8255 outputs are set to Active Low PAUSE 50 'HOLD TIME FOR 50 MS RETURN PortA_8255: 'Set up 8255 Port A for Output LOW A1_8255 'Set Address control A1 & A0 Low to set the 8255 Port A for Output PAUSE 50 LOW A0_8255 PAUSE 50 RC_OUT = pattern1 'Set databus for pattern1 LOW CS1_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 1 'Pulse Write control Low (Active) for 10 us (port changes state) PAUSE 50 HIGH CS1_8255 'Set Chip Select High (Inactive) - Disable the 8255 databus PAUSE 50 'HOLD TIME FOR 50 MS RETURN PortB_8255: 'Set up 8255 Port B for Output HIGH A1_8255 'Set Address control A1 & A0 to set the 8255 Port B for Output LOW A0_8255 RC_OUT = pattern2 'Set databus for pattern2 LOW CS1_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 1 'Pulse Write control Low (Active) for 10 us (port changes state) HIGH CS1_8255 'Set Chip Select High (Inactive) - Disable the 8255 databus PAUSE 50 'HOLD TIME FOR 50 MS RETURN PortC_8255: 'Set up 8255 Port C for Output LOW A1_8255 'Set address control A1 & A0 to set the 8255 Port C for Output HIGH A0_8255 RC_OUT = pattern3 'Set databus for pattern3 LOW CS1_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 1 'Pulse Write control Low (Active) for 10 us (port changes state) HIGH CS1_8255 'Set Chip Select High (Inactive) - Disable the 8255 databus PAUSE 50 'HOLD TIME FOR 50 MS RETURN ' ========================================================================= ' User Data ' ========================================================================= 'Pgm_ID: ' DATA "SX/B 1.50 Template", 0 THIS SX-28 PROGRAM (ABOVE) DOES NOT WORK THIS BS2 PROGRAM (BELOW) DOES WORK ---- WHAT IS DIFFERENT BETWEEN THEM? [/code] [code] ' {$STAMP BS2px} ' {$PBASIC 2.5} ' ' 8255 PPI IC - Test program with 24 outputs available. ' Written by Timothy Gilmore ' 10/15/06 ' ' Test program using the 8255 and BS2PX (OR BS2). ' ' ----- Constants Reset_8255 PIN 8 WR_8255 PIN 9 A0_8255 PIN 10 A1_8255 PIN 11 CS_8255 PIN 12 ' 3 additional 8255 chips can be used when using: ' CS2_8255 PIN 13 ' CS3_8255 PIN 14 ' CS4_8255 PIN 15 ' This would provide 24+24+24 additional inputs and/or outputs (96 I/O lines possible) ' Modify the code below to add the 3 additional Chip Select lines if needed to add more 8255's. ' ----- Variables pattern1 VAR Byte pattern2 VAR Byte pattern3 VAR Byte ' ----- EEPROM Data ' ----- Initialization OUTS = $00 ' Set Outputs Low DIRS = $FF ' Set I/O Direction GOSUB Initialize_8255 ' ----- Main Code Main: pattern1 = %10101010 'Set pattern for Output Ports (Read it in reverse) pattern2 = %11110000 pattern3 = %00110011 GOSUB PortA_8255 GOSUB PortB_8255 GOSUB PortC_8255 GOTO Main ' ----- Subroutines Initialize_8255: 'Initialize 8255 to All Outputs at Active Low state OUTH = $FF 'Set all the control lines (P8-P15) High (Inactive) PAUSE 50 'Settling time for a few ms (50 ms) LOW Reset_8255 '8255 is Reset (Active) HIGH WR_8255 'Set Write control High (Inactive) HIGH A1_8255 'Set Address control A1 & A0 High to access the control word register HIGH A0_8255 OUTL = $80 'Set databus (P0-P7) to $80 for MODE 0 - All 3 ports as outputs LOW CS_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 50 'Pulse Write control Low (Active) for 100 us (duration not critical) HIGH CS_8255 'Set Chip Select High (Inactive) - All outputs are set to Active Low RETURN PortA_8255: 'Set up 8255 Port A for Output LOW A1_8255 'Set address control A1 & A0 Low to set the 8255 Port A for Output LOW A0_8255 OUTL = pattern1 'Set databus for pattern1 LOW CS_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 5 'Pulse Write control Low (Active) for 10 us (port changes state) HIGH CS_8255 'Set Chip Select High (Inactive) - Disable the 8255 databus RETURN PortB_8255: 'Set up 8255 Port B for Output HIGH A1_8255 'Set address control A1 & A0 to set the 8255 Port B for Output LOW A0_8255 OUTL = pattern2 'Set databus for pattern2 LOW CS_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 5 'Pulse Write control Low (Active) for 10 us (port changes state) HIGH CS_8255 'Set Chip Select High (Inactive) - Disable the 8255 databus RETURN PortC_8255: 'Set up 8255 Port C for Output LOW A1_8255 'Set address control A1 & A0 to set the 8255 Port C for Output HIGH A0_8255 OUTL = pattern3 'Set databus for pattern3 LOW CS_8255 'Set Chip Select Low (Active) PULSOUT WR_8255, 5 'Pulse Write control Low (Active) for 10 us (port changes state) HIGH CS_8255 'Set Chip Select High (Inactive) - Disable the 8255 databus RETURN [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=150716#m150980 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)