Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

programming a byte on one pin

Status
Not open for further replies.
I realize that it is not that difficult. Been investigating all the aspects of this shift register. Found out I need to clear the register between sub-rountines as I get left over LED(bits) enabled.
Will try again on firing the rows as I attempted that with unsuccessful results. I re-configured the High Side driver inputs so all 7 inputs are on the same portB (was worried about using the B.6 / PGC pin.
Tried using PORTB.bITS(x) = 1 then do a for next loop but I have an issue with the OUTPUT enabled. Using PORTB.1=1 dosen't seem to want to coporate. But using HIGH(row0) works just fine.
Going to try and add just the row data between the colum data BUT I have 5 colum data and 7 row data. Will get back at it. Was thinking an array like I have in the LOAD sub routine.
 
By joe I got it working.
I inserted a counter that increments Rows(x)
seems to work pretty good.
need to cnfigure out where I messed up my row connections. not in right order after I moved pin connections around so ALL of the rows are on PORTB
 
I got over the hurdle of enabling the rows in sequence along side the colums. Working on making the graphic scroll across the display.
Still contemplating having separate connections to the TLC5916's (each have its own LE and OE connections to the PIC) Hopefully this will eliminate leftover bits and color mixing.
Last night I was experimenting with the delay time and found I could get the matrix to display two seperate arrows at the same time and no flickering.
Would be a nice piece odf test equipment to be able to test the LED intensity comparing different delays settings. A simple photo transistor w amp and meter (light meter). I have all the parts leftover from the LIGHT lISTENER project, maybe a side track project??
 
curious as to WHY the dang PIC takes so long to get going?
Have the internal ocs enabled at 32 but it takes about 30 seconds AFTER I program the PIC before the LEDs even come on.
BUT when it does I get a leftover? bit comes on?
Thinking of inserting a %00000000 but the bit that comes on is towards the end of the CONST array. Going to look into using a STEP instead of all the 12 CONST elements(12 for rows and 12 for colums).
Going to take a break, been at it getting slow progress.
 
Include "InternalOscillator.bas you need that with the right setting and clock 16 is wrong too I bet set it to
clock = 8


Now I don't no but I think nternalOscillator.bas is the one that set's by the clock setting

But your chip has no 16 mhZ clock 8 is it without setting pll and I'm sure that's not set.

You should use a crystal till you get this stuff down pat.
 
Last edited:
I have this assembled on a perfboard and didn't really want to add a crystal but I may just do it.
Will recheck my code for the oscon setting.
Using the internaloscilliator.bas
 
Mrdeb you missed a part there is no clock = 16 on that chip with out pll and from what your saying the clock is running slow
 
Last edited:
This is what I have that works

going to rat shack for some 22pf caps to connect a crystal.
I looked at the internalosc.bas and it supposedly sets the oscon registers etc.
This scrolls an arrow across the matrix. Hopefully will stumble on to why on power up I get a segment that blinks once then the roiutine proceeds as wanted. Thinking maybe I need to disable the LE inputs as well as the OE inputs. Going to bed.
Code:
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 11/12/2012                                                     *
*  Version : 1.0                                                            *
*  Notes   : Burts knight rider                                                               *
*          :                                                                *
*****************************************************************************
}
Device = 18F2420
Clock = 8
//Config OSC = INTIO67
Include "InternalOscillator.bas " 
Include "shift.bas"
Include "utils.bas"
Include "convert.bas"
Include "InternalOscillator.bas " 
Dim SDI As PORTC.4
Dim CLK As PORTC.5
Dim LE As PORTC.3
Dim RED_OE As PORTC.0
Dim GREEN_OE As PORTC.1
 
Dim DataPin As SDI  
Dim ClockPin As CLK
Dim ResetPin_R As RED_OE
Dim ResetPin_G As GREEN_OE
Dim index As Byte 
Dim X As Byte
{
Dim row0 As PORTB.0
Dim row1 As PORTB.6 
Dim row2 As PORTB.1 
Dim row3 As PORTB.2
Dim row4 As PORTB.3
Dim row5 As PORTB.4
Dim row6 As PORTB.5
Dim led As PORTA.0
} 

Dim colum_buffer(5) As Byte
Dim Z As Byte


Const data(12)As Byte = (%00010001, %00001010 ,%00000100, %00010001, %00001010, %00000100, 
%00010001, %000001010 ,%00000100, %000010001,%00001010, %00000100)
 
Const Rows(12) As Byte =(%00000001, %000000010 ,%00000100, %000000010, %00000100, %00001000,
 %00000100 ,%000001000 ,%00010000 ,%00001000,%00010000 ,%00100000)
                      
Sub LOAD()
    For Z = 0 To 4           
colum_buffer(Z)= data(Z)            
Next       
End Sub

Sub StartScan()
    LE = 0
    ResetPin_G = 1
    Shift.Out(MSB_FIRST, X ,8)  
    LE = 1         //Latch data
    PORTB =Rows(Z)  
    DelayuS(10)
    ResetPin_G = 0  // output disable
    LE = 0
    Z = Z+1
End Sub

Shift.SetOutput(DataPin)
Shift.SetClock(ClockPin)
ADCON1 = $07 
Output(ResetPin_R)
Output(ResetPin_G)
Output (LE)

// start of main
While true 
  Z = 0  
 For index = 0 To Bound (data)
      DelayMS(100)
      X = (data(index))
  StartScan
  Next
  TRISB = %00000000
 Wend
 End
 
Well I knew I should have connected a crystal to begin with but I hope to get it working without a crystal after I am all done.
Been adjusting my delays trying to get a SMOOTH transition between arrows. I at one point had two arrows frozen on the matrix. This experimenting got me to wondering if there is a formula for computing delays between getting data and length of time to display data.
Not real concerned at this point as the delays will change after running the PIC without a crystal in my final design.
 
Not real concerned at this point as the delays will change after running the PIC without a crystal in my final design.

Huh? Wouldn't a delay of X mS be the same as long as the clock frequency is specified correctly? Doesn't the compiler handle the details?
 
Yep he has his code wrong if you look at the includes you'll
See what's happening here your including the osccon bad two
Times that means the compiler includes the last one which
Takes forever to load and run
The compiler sets the delay with the clock =xx statement
So it doesn't matter if you have a 4 or 32 MHz crystal
The delay is the same
 
Ah yes I see the osccon way down in the code. I missed that one.
Trying to get the arrow to go left. Tried using a STEP-?? but felt a CONST array reversed what the Rows array has.
Will post a video AFTER I get it straighen out.
 
Yep that should be set to config osc = INTIO67
this is what he should have

If Mrdeb want's a INtOSC with a clock of 16
Code:
Device = 18F2420
Clock = 16
CONFIG OSC = INTIO67
Include "InternalOscillator.bas " 
Include "shift.bas"
Include "utils.bas"
Include "convert.bas"
Your setting should be like that.
 
missing some additional required information.

No it's not go back where you came from and read up on the
InternalOscillator.bas
that andy wrote it set's the dang thing right IF you use it RIGHT that's the problem

If you set the OSC to use the Internal Oscillator you can't use osccon setting and use modules with Swordfish the setting don't get set till Swordfish run down the list of Modules and good old Mrdeb
had the dang thing in there two times which skips the first one and used the second one.

Then after I told him to use a crystal he must of commented out the CONFIG OSC = INTIO67 one more mess.

And Jon you need to remember you wrote this
I will be the first to admit that I don't know much about using the internal oscillation. In fact, in Commandments for Using PICs, I recommend against it as there are several traps that users fall into that prevent successful operation.

If MrDeb is using andy's InternalOscillator.bas and this at Start of code the chip will work fine
Code:
Device = 18F2420
Clock = 16
CONFIG OSC = INTIO67
Include "InternalOscillator.bas " 
Include "shift.bas"
Include "utils.bas"
Include "convert.bas"

And one more thing @ MrDeb when you commented out code write down why and what for and you'll save yourself a bunch of time figuring what went wrong.
 
Last edited:
And Jon this will not even compile
Code:
Device = 18F2420
Clock = 32
Config OSC = INTIO67
OSCCON = %01111100 // Sets up the internal oscillator
OSCTUNE.6 = 1  // Enables PLL

Why OSCCON = %01111100 OSCTUNE.6 = 1 can't be set before your Module are included
That's why people started putting these setting in a module to set them as a work around for swordfish
And one More thing I pointed this out a long time ago and then there started a wave of INtOSC.bas to set these setting even pointed this out to GRAM That his LCD sample didn't run for almost 30 minutes because of the way Swordfish handled modules.
 
I should start commenting on the comment out sections of code. I have a crystal installed but will try the internal osc again but use the 16 as well as suggested.
I hopefully will stir clear of any further clock screw-ups. Will try out what Burt suggested before going any further. Oh by the way I have an LED that blinked at what seemed the correct 1 second interval while I had the internal OSC setup.
Meanwhile the lone ranger is back at the ranch racking his balls------------------playing pool
I ran into another conflict as well as discovered why I was getting color mixing.
I wanted to use an interrupt to change from SUB LEFT to SUB RIGHT. But I have all of portB connected to the High Side driver.
Before I make a bigger mess, I was contemplating just using two other port pins, say PortA.0 and PortA.1. If A.1 goes LOW then SUB RIGHT, if A.1 goes LOW then SUB LEFT.
In simple terms, can an interupt be implemented on most any other Port pin besides PortB.0,1 or 2?
 
PortB is the only port interrupt on change and that for inputs What makes you think you need that. And there is 4 pins on that chip that have interrupt on change
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top