Quantcast
Channel: MEL PICBASIC Forum
Viewing all 4787 articles
Browse latest View live

Newbie SPI question

$
0
0
Before I part with cash to get an SPI TFT display, I would like some advice on how the SPI works, and is it similar to using LCDout or i2cwrite commands ?

For example can I send something like shiftout address, command, X, Y ["hello world"] ??

Whilst I know is graphical, but basically I'm only requiring the ability to display text to the screen

size for the iPhone series came with the iPhone 5

setting to the last time

quick changing of ports for I/O use

$
0
0
Hi guys , was wondering where i should look in the electrical specs for the chip where the ports settle time between changing port inputs to output and back

have need to do fast transition of direction over a group of port pins over several ports

cheers

Sheldon

High Voltage NiMH battery charger

$
0
0
I am trying to get info on building a high voltage hybrid car NiMH battery charger.

They are based on 28 cells of 7.2 volt/6.5Ah in series resulting in a 201,6 volts (much higher when charged).

One idea is to seperate the battery cells and make 28 discreate chargers but this leads to higher cost.

The other idea is to have one high voltage charger of about 300 Volts max at 0.1-0.2C with timer and voltage circuits to monitor the process.

Any ideas welcome,

Ioannis

PIC10F220 RC filter first order

$
0
0
I want to make an electronic device that Measures the wind speed in Beaufort. The definition of the Beaufort scale requires the calculation of an average over a period of 10 minutes. We choose to do this using the following principle (average with forgetfulness):

For economical and space reasons, we choose to realize the RC filter by numerical simulation in the microcontroller.
Power supply: 3V analog output voltage proportional to the Beaufort scale with 0 corresponding to 0V Beaufort, 3V corresponding to 9 Beaufort (it will not show values above 9 Beaufort)
Interface to the LCD module: SPI (SPIdatas and SPI clk) Wind speed encoded in 8 bits

I expected to find some help here because I have almost no idea how to program in assembly language.
I have difficulties and problems understanding the management and integration of SPI communication and problems And difficulty as the exact conversion speed => Beaufort and how to use it, and to make a sliding average

The code is highly optimized That's why I come to ask your help :fs: and knowledge. Any ideas is welcome!

Thanks

internal eeprom problem

$
0
0
Iam working with 16F876A.i want to store and read two different word in eeprom at different locations.
For first word i used

Write 0,numb.highbyte
Write 1,numb.lowbyte

What be for second word?
Second word is Tempp

Disable/Enable DT interrupt

$
0
0
Hi all, I need help in understanding how I can disabile temporarely the DT interrupt on the serial receive (RX_INT) and Enable it as soon as the special event is ended.

Anybody has faced such a need before?

Cheers

Al.

World’s First Internet Connected Lawnmower

Old Chestnut ? - 128 x 64 GLCD

$
0
0
I'm still evaluating options to display info for a revamp of my old Vivarium Controller project, and whilst the tests with an I2C module that piggybacked on the back of a KS0108 GLCD have proved difficult, the other option is to use traditional wiring to the 20 pin header, and with a bit of juggling around I might just be able to free up the extra pins required.

Anyway, I have a MicroElektronica EasyPIC5 board and their 128 x 64 mono (Blue/white) GLCD. Using a 16F877A, 20mhz crystal and their own example HEX program the file loaded and ran through the demo just fine, so I know the hardware works. Now I only have the demo version of Mikro Basic and I can't re-compile the example code for my target PIC and desired OSC speed as it exceeds the limit, so I went hunting for some examples for PBP and came across this - courtesy of Ranjit Diol - (I've changed the LCD pins to match the pinouts of the LCD I have as the original use different ports)

Code:

ASM 
  __CONFIG    _CONFIG1H, _OSC_HSPLL_1H
  __CONFIG    _CONFIG2L, _PWRT_ON_2L 
  __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
  __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
  __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM

DEFINE  OSC 20
ADCON1 = $0F
clear


'************************************************************************
'                  IMPORTANT, PLEASE NOTE THE FOLLOWING
'This application assumes you have a 64KBit external eeprom connected
'via I2C. Without that you will only be able to send images directly
'to the LCD display and not be able to store them -- See the readme.txt
'for the Windows GLiPIC interface.
'
'Adjust the PIN assignments as neccessary for your prototype
'This was tested using a 20MHz xtal if you use a different OSC speed
'you may have to make some adjustement in the 'strobe' subroutine.
'************************************************************************




                                'routine's e_pause constant for other speeds
ADCON1        = 7                        'Make all pins digital, you may adjust as needed


lcd_dat        VAR        PORTD                'LCD bus Pins 7-14 LSB-MSB
scl        VAR        PORTC.3                'I2C SCL  for ext eeprom
sda        VAR        PORTC.4                'I2C SDA for ext eeprom
in_pin  VAR    PORTC.7        'Serial input pin
out_pin  VAR    PORTC.6        'Serial output pin
lcd_e        VAR        PORTB.4                'Enable pin on LCD
lcd_cd        VAR        PORTB.2                'Data/Command  R/S on LCD
lcd_rw        VAR        PORTB.3                'Read/Write on LCD
lcd_cs1        VAR        PORTB.0                'ChipSelect1  on LCD
lcd_cs2        VAR        PORTB.1                'ChipSelect2  on LCD
lcd_rst        VAR        PORTB.5                'Reset Pin on LCD

'Set pins for output
TRISB.0  = 0
TRISB.1  = 0
TRISB.2  = 0
TRISD        = 0
TRISb.0        = 0
TRISb.1        = 0
TRISb.2        = 0
TRISC.3        = 0
TRISC.4        = 0
TRISb.5        = 0

'Constants used
ser_baud  CON    84            '9600 baud serout/serin
ctl      CON    $A0                'EEprom control code
row          CON        $b8                'LCD page 0
last_row  CON    $bf                'LCD page 7
col          CON    $40                'Line byte position 0
last_col  CON    63            'Last column (1-64)
first_col CON    0                'First column
max_col  CON    128            'Last column (1-127)
max_line  CON    8                'Line 8 (based on 1-8)
max_pos  CON    64            'Column 64 positon per side (1-64)
cr        CON    13                'CR for serout
lf        CON    10                'LF for serout
disp_on  CON    $3f                'LCD Display ON
disp_off  CON    $3e            'LCD Display OFF
disp_ram  CON    $c0            'Ram Display 0 (Page 0 at top of display)
blank    CON    $00                'Blank character
e_pause          CON    6                'Pauseus 6 for Strobe routine

'Word variables used
eepaddr  VAR    WORD
addr    VAR    WORD

'Arrays used
in_array VAR    byte[32]
in_ctl  VAR    byte[8]

'Byte Variables used
buff_count VAR  BYTE        'buffer count
hex_nibble VAR  BYTE        'hex nibble from serin
in_ascii  VAR  BYTE        'ASCII char from serin
buf_cnt    VAR  BYTE        'buffer counter
byte_pos  VAR  BYTE        'To keep track of a byte's position
in_byte    VAR  BYTE        'The incoming byte
tmp          VAR        BYTE        'Temporary var
index          VAR        BYTE        'Index for arrays
j          VAR  BYTE        'General counter
k          VAR  BYTE        'General counter
line          VAR  BYTE        'An LCD row
delay      VAR  BYTE        'Execution delay, used with 'pause'

'Initialize variables
hex_nibble = 0
byte_pos  = 0
delay      = 10
in_byte    = 0
tmp        = 0
index      = 0


'Reset LCD
lcd_dat = 0        ' Clear PORTD
lcd_cd =  0
lcd_rw =  0
lcd_e =  0
lcd_cs1 = 1
lcd_cs2 = 0
lcd_rst = 1
pause 100        'Let things  stabilize
lcd_rst = 0
pause 10        ' Reset LCD
lcd_rst = 1
pause  500


'Jump over subroutines to main program
goto main

' **** (GO)SUB ROUTINES ****

strobe:
        lcd_e = 1
        pauseus e_pause
        lcd_e = 0
return

clearall:
        lcd_cd = 0                ' Command mode
        lcd_dat = disp_off        ' Display Off
        gosub strobe
        lcd_cs1=1
        lcd_cs2=0
        for index = 1 to 2
          for j = row to last_row
                lcd_cd = 0                'Command mode
                gosub strobe        ' Write the data
                lcd_dat = col        ' Column address = 0
                gosub strobe
                lcd_dat = j
                gosub strobe       
                lcd_cd = 1                ' Write mode
                  for k = first_col to last_col
                    lcd_dat = blank
                    gosub strobe
                  next
          next
          swap lcd_cs1,lcd_cs2
        next

        lcd_cs1=0
        lcd_cs2=1
        lcd_cd=0
        lcd_dat=row
        gosub strobe
        lcd_dat = disp_ram        ' Ram Line 0
        gosub strobe
        lcd_dat=col
        gosub strobe
        lcd_cs1=1
        lcd_cs2=0
        lcd_dat=row
        gosub strobe
        lcd_dat = disp_ram        ' Ram Line 0
        gosub strobe
        lcd_dat=col
        gosub strobe
        lcd_dat = disp_on        'display on
        gosub strobe
        lcd_cd = 1                ' Set Data command
        lcd_cs1 = 1                ' Left side active
        lcd_cs2 = 0

return       


init:                        'Initialization

        lcd_cd = 0                        ' Set command mode
        lcd_cs1 = 1                        ' Left Side on
        lcd_cs2 = 0                        ' Right Side off       
        for index = 1 to 2
          lcd_dat = disp_off        ' Display Off
          lcd_dat = disp_ram        ' Ram Line 0
          gosub strobe                ' Write the data
          lcd_dat = col                ' Y address = 0
          gosub strobe
          lcd_dat = row                ' Page = 0
          gosub strobe
          lcd_dat = disp_on        ' Display On
          gosub strobe
          swap lcd_cs1,lcd_cs2
        next
        lcd_cs1=1
        lcd_cs2=0


return

'****Place char on LCD Routine *****
'Place byte of data on lcd assumes in_byte, byte_pos and line (line)
'Char position on LCD byte_pos = 0-127 (Horiz), ROW 0-7 (vert)

putbyte:
        lcd_dat = in_byte                'Display the byte
        gosub strobe 
        byte_pos=byte_pos+1        'Increment position

        'Now do some LCD house cleaning and adjust counters
        if byte_pos=max_pos then
          lcd_cs1=0
          lcd_cs2=1
          lcd_cd = 0
          lcd_dat = col
          gosub strobe
          lcd_dat = disp_ram
          gosub strobe
          lcd_dat = row + line
          gosub strobe
          lcd_cd = 1
        endif
    if byte_pos = max_col then        'Check if
          line = line + 1                'New Line
              if line = max_line then
                line = 0
              endif
            byte_pos = 0                'Reset byte_pos
        lcd_cs1=1
        lcd_cs2=0
        lcd_cd = 0
        lcd_dat=col
        gosub strobe
        lcd_dat = row + line
        gosub strobe
        lcd_dat = disp_ram
        gosub strobe
        lcd_cd =1
    endif
 
return

'***** Convert incoming ascii to hex byte Routine *****
find:
Lookdown in_array[index],["0123456789abcdef"],hex_nibble
return       


'===============================
' **** BEGIN MAIN PROGRAM ******
'===============================
       
main:
        gosub init        ' Initialize LCD
        gosub clearall        ' Clear all pages
goto term

logo:        gosub init        ' Initialize LCD
        gosub clearall        ' Clear all pages



'**** DISPLAY IMAGES IN EXTERNAL 64KBit EEPROM VIA I2C *****

' Load opening screen from eeprom assuming a 64KBit eeprom

        byte_pos=0
        line =0
        for addr = 0 to 8192                'Eight 1kbyte pages of eeprom
        I2CREAD sda,scl,ctl,addr,[in_byte]
        gosub putbyte

        if (addr=1024) OR (addr=2048) OR (addr= 3072) OR (addr=4096) OR (addr=5120) OR (addr=6144) OR (addr=7168) OR (addr=8192) then
        pause 4000

        gosub init
        gosub clearall
        endif

        if addr=8192 then
        addr = 0
        endif

        next

goto logo                'Continue looping inifitum!

'********************************************

'Terminal Subroutine
term:                'Assumes Home Position

'Setup variables
j=0
index=0
k=0
line=0
addr=0
in_ascii = 0
buff_count = 32
delay = 10
addr = 0
byte_pos = 0

'Get the initial parameters
get_param:
        serin2 in_pin,ser_baud,[wait ("*"),STR in_ctl\9]
        for index = 0 to 8
        Lookdown in_ctl[index],["0123456789abcdef"],hex_nibble
        in_ctl[index]=hex_nibble
        next
        delay = (in_ctl[7]<<4) | in_ctl[8]
        buff_count = (in_ctl[1]<<4) | in_ctl[2]
        addr.byte1 = (in_ctl[3] <<4) | in_ctl[4]
        addr.byte0 = (in_ctl[5] <<4) | in_ctl[6]
        buf_cnt = (buff_count - 1)
        eepaddr = addr
        j=in_ctl[0]
        if j = 0 then lcd_loop                'Display directly on LCD
        if j = 1 then eep_loop                'Load ext eeprom
        if j = 2 then logo                'Display images loop
        goto get_param   




eep_loop:
       
        serin2 in_pin,ser_baud,[wait ("]"),STR in_array\buff_count]        'Wait for ] and the load in_array

        for index = 0 to buf_cnt
                'Get char and place in array
                Lookdown in_array[index],["0123456789abcdef"],hex_nibble
                in_array[index]=hex_nibble
        next

        for index = 0 to buf_cnt step 2
                in_byte = (in_array[index]<<4) | (in_array[index+1])        'Form a hex number MSB-LSB
                I2CWRITE sda,scl,ctl,eepaddr,[in_byte]
                pause 10
                eepaddr=eepaddr+1               
        next
goto eep_loop

lcd_loop: 
        serin2 in_pin,ser_baud,[wait ("]"),STR in_array\buff_count]        'Wait for ] and the load in_array

        for index = 0 to (buff_count - 1)
                gosub find                        'Get char and place in array
                in_array[index]=hex_nibble
        next
       
        for index = 0 to (buff_count - 1) step 2
                in_byte = (in_array[index]<<4) | (in_array[index+1])        'Form a hex number MSB-LSB
                gosub putbyte
       
       
        next


goto lcd_loop

It compiles fine for the 18F4580 I'm using, but I don't get anything on the display... I did notice that some links included a controller board (http://www.piclist.com/techref/io/lcd/ks0108.htm) but then this really is a PIC with MAX232 and EEPROM all on one board so shouldn't really make any difference for the code not to display something ?

All I'm really after is for the GLCD to behave as if it were an 8 line x 21 character display - nothing fancy, but on an 18F4580 running at 40 Mhz off a 20 Mhz xtal.... if someone could suggest a simple equivalent of the "hello world"LCD code, or correct me if there are any reasons why this seems such a steep hill to climb with PBP I would be most obliged

Malcolm

Want to display less decimal places on LCD from 16bit ADC

$
0
0
Hi all,

I am reading a 0-10VDC signal with a 16-bit ADC.

So I am taking the LONG (just in case I need the room later) variable that I am reading that 16bit number into, lets say 10 volts for %1111111111111111 (65535) and multiplying it by 15259 to get = 999998565

And then to read it out on my LCD, I'm doing the typical:

LCDOUT $FE, 1 DEC myADCvariable / 100000000, "." , DEC8 myADCvariable // 100000000

to get a nice decimal representation of the voltage = 9.99998565

The issue is that I want to only see the first 4 decimal places to the right of the decimal, as there is some noise (out of my control, reading from a board that has the 16bit ADC and I can't add filter caps to it etc.) and the last few bits flip around.

I've tried everything that I can think of, but not coming up with a solution.

If I try: LCDOUT $FE, 1 DEC myADCvariable / 100000000, "." , DEC4 myADCvariable // 1000 - then I get = 9.8565 and those last four digits are going crazy... and they are the wrong 4 digits anyway!

I need = 9.9999 (well closer to 10.0 whatever with a calibration factor, but one problem at a time.)

What do I need to be doing to only get the decimal places I need and mask the ones I don't? :confused:

Thanks!

Ryan

HSEROUT with Timer2 Interrupt

$
0
0
I am using a PIC18F87K22 micro. I have timer2 setup with PR2 to generate an interrupt 250 times per second
'setup timer2
'Fosc/4 with prescaler=16 AND postscaler of 16 yields 62,500 Hz, count of 250 gives interrupt every 250th of a second
'64mhz/4 = 4 mhz............16mhz/256 = 62500 hz.....use for 64 Mhz clock
PR2 = 249 'Timer2 Period Register
T2CON = 111110
PIE1.1 = 1 'enable the timer2 interrupt

Both UARTS are set to 19,200 baud (actually 19,230)

Each UART will generate an interrupt if a character arrives and I can read both serial ports without any issues whatsoever.

It is when I send characters where it appears that the UART timing seems to go screwy and the receiving
computer gets strings with incorrect or missing characters

If I transmit an array this way
HSEROUT2 [STR SENDBUFF\30]
It does not work. But if I disable the timer2 interrupt it works fine.

However if I use assembly the timer2 interrupt does not affect it at all.

FOR I = 0 TO 29
SENDCHAR = SENDBUFF(I)
GOSUB SENDCOM2
NEXT I

SENDCOM2:
;MOVFF source, destination = move source reg to dest reg
@MOVFF _SENDCHAR,TXREG2
CHECKCOM2:
@MOVFF TXSTA2,_SENDCHAR
IF SENDCHAR.1 = 0 THEN GOTO CHECKCOM2 'wait until transmit buffer is empty
RETURN

Suggestions?

two serial ports

$
0
0
Guys,

Quick question, is it possible to have a hardware serial port and a software serial port running on the same PIC with the same code.

Th existing code uses the hardware port (pins RC6 and 7) to communicate with a PC application. The application is used to update and configure the unit rather than as a constant monitoring appliaction, so it's not in "constant" use, but the polling is run each time the cod loops. I now need to use a serial piggy module for my glcd, which will be used constantly to update the GLCD. Is it possible to set a pin up and use software serial commands whilst at the same time using the hardware option.

The module can use i2c / SPI / or Serial, but at the moment, i2c seems problematical compared to serial.

Cannot drive I2C Oled :(

$
0
0
Hello guys, I tried to drive a 0.96" 128x64 I2C oled screen whole week and I'm about to go crazy because of this... I'm able to run the screen with arduino but I want to do it with a 877f (well I'm stubborn...)
My oled screen using ssd1306 driver and I read it's datasheet, I examined all lines of arduino codes and PICC codes (I didn't try PICC codes just viewed) But I wasn't able to run the screen :\ I can't see if I'm missing something or there is something I don't know about. Is there anyone who used these oled screens with PIC ? Or any hint what might I'd be missing.

I worked on CircuitDomain's codes and tried many changes on it but none work in the end... I started with this topic : http://www.picbasic.co.uk/forum/showthread.php?t=17973

N
ow I'm just trying to see a working pixel on screen, and these are my codes;
Code:

'==========================MCU SETUP============================================ 
Include "modedefs.bas"
DEFINE OSC 16
DEFINE I2C_SLOW 1 'to use 100kHz device over 4MHz oscillator
DEFINE I2C_HOLD 1


OPTION_REG=0
ADCON0=0
ADCON1=7
TRISA=%00111111
TRISB=%00000001
TRISC=0






'================================usuart========================================


'==============================BAUD SETUP=======================================


I2CDevice var byte
SCL var PortC.3        ' I2C Clock  PortC.3
SDA var PortC.4        ' I2C Data  PortC.4
DC VAR byte' "DATA OR COMMAND", $40=DATA; $80=COMMAND
LCD_DATA VAR BYTE
COM VAR BYTE'COMMAND




I VAR BYTE
J VAR BYTE
X VAR BYTE' LCD POSITION X(0 TO 127)
Y VAR BYTE'LCD POSITION Y(0 TO 7)
CLEAR
'=============================================================================
'PAGE = $B0


I2CDevice = $78      'Display Address = $78,


PAUSE 20


GOSUB INIT




MAIN:


gosub FILL
pause 1000
gosub CLEAR_LCD
pause 1000


GOTO MAIN




'=========================lcd initialization====================================
INIT:


COM=$AE:GOSUB SEND_COMMAND' DISPLAY OFF
pause 10
COM=$20:GOSUB SEND_COMMAND' ADRESSING MODE
COM=$02:GOSUB SEND_COMMAND' Page adressing mode
COM=$81:GOSUB SEND_COMMAND' Send contrast
COM=$FF:GOSUB SEND_COMMAND'
COM=$A4:GOSUB SEND_COMMAND' display on continue
COM=$A6:GOSUB SEND_COMMAND' $A6=NORMAL MODE;$A7=INVERSE MODE
COM=$AF:GOSUB SEND_COMMAND' DISPLAY ON
pause 10
 gosub CLEAR_LCD
 return
'===============================================================================
'==============================clear lcd========================================
CLEAR_LCD:




  FOR J=0 TO 7
    FOR I=0 TO 127
        LCD_DATA=$00:GOSUB SEND_DATA 
    NEXT I
  NEXT J                           


RETURN


'****************SEND COMMAND************************************************


SEND_COMMAND:
dc=$80


I2CWrite SDA,SCL,I2CDevice,DC,[COM]


RETURN
'*****************************************************************************


'======================Send data===============================================
SEND_DATA:
DC=$40


I2CWrite SDA,SCL,I2CDevice,DC,[LCD_DATA]


RETURN
'===============================================================================
'=============================FILL=============================================
FILL:
FOR J=0 TO 7
FOR I=0 TO 127
LCD_DATA=$FF:GOSUB SEND_DATA
NEXT I
NEXT J
RETURN
'===============================================================================


'===========================================SET X AND Y=========================
SET_XY:
COM=$21:GOSUB SEND_COMMAND
COM=X:GOSUB SEND_COMMAND
COM=127:GOSUB SEND_COMMAND
COM=$22:GOSUB SEND_COMMAND
COM=Y:GOSUB SEND_COMMAND
COM=Y:GOSUB SEND_COMMAND
RETURN
'===============================================================================
END

POWER USED BY 18F ver 18LF CHIPS

$
0
0
HI guys ,

i have application where power is really an issue on small batteries and i have used only the 18F version upto now , is there a real power saving when using the 18LF version of the chips ?

application uses 3.3volts
cheers

Sheldon

Quick question - how to use 0x27 as an address in i2c

$
0
0
I'm wanting to write to an address of 0x27. PBP seems to suggest that $42 is the format to use, although most conversion charts state that this is 39 not 42 ?

I'm confused as I have two i2c piggy back boards that use I2C and code written to it in PBP fail to do anything to the display (but work fine over serial). I've tried $42 $39 $4E and still it fails to do simple task like turn the backlight off etc)

how to implement DIM AS CODE

$
0
0
hello,

i am trying to write code for my 5*5*5 led cube. this is a test setup before i start building my 8*8*8 RGB led cube to avoid any errors in the final project.
i am of course using shift register to extend the amount of outputs, however the electronics itself are not the problem since i am struggeling with the code.
i already did get the shout command working and also used array's bud the downside of that is that they are stored as variabels.
so i was looking for a method to store the data in the flash memory of the pic, i found the following command: DIM ...... AS CODE in the documentation.
it is able to do exactly what i want. bud the documentation doesn't tell me how to implement it. i would like to store 8bit values, so it should look a bid like this:

%10000000
%11000000
%11100000

i want to store data tables that the program needs to walk trough one by one. the problem is how can i write this kind of data table to the flash memory with the DIM .... AS CODE command?

thanks in advance

Pic Basic has a analogue to digital converter

$
0
0
Is it possible to use a Pic Basic has a analogue to digital converter or has a interface.

For example reading a voltage from 0 to 5 volts so it can be converted into digital by the Pic Basic and fed into the USB of a computer.


Thanks heaps.

Any transparent GLCD displays available

$
0
0
For coolness does anyone know of a transparent GLCD probably an OLED?
Transparent as in see thru where no data is displayed?
Price point isn't the main factor as this is for fun.
Perhaps for use in a car over an existing display where space is limited?

Norm

USB U2 Not programming ?

$
0
0
USB U2 Not programming ?


Any body knows please Help:
PS: My first languish is German
typing on a German keyboard


I have installed :


PBP #3 Gold
Micro Code Studio Plus V 5.0.0.5
Compiler V PBPX 3.0.6.4
MPLAB IDE V 8.85


Programmer : USB U2 melabs 4.5. Firmware 5.9
Chip Target info ID 09A4 (16F877)


My problem started when I tried toprogram PIC16F88.


So I went back to BASICs:
I use the USB U2 melabs with a LAB-X2from meLAB
Chip is 16F877-20/P .
Yes power is supplied to the LAB-X2
My programmer gets power from a poweredUSB Port


My program is blink3x2 from meLABsample library for the LAB-X2
When I go [program compile inMicro CodeStudio] it appears every thing is fine however
the red programming LED on the U2Programmer is not flashing !
And I don’t get the desired resultson the LAB-X2


When I program from the meLABProgrammer it appears to program just
fine [the red led isflashing].unfortunate I don’t get the desired results on the LAB-X2.
Except now the hex code is changed!

Code:

' Name        : BLINK3X2.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler  : PM or MPASM
' Target PIC  : 28/40-pin PIC types compatible with LAB-X2 board
' Hardware    : LAB-X2 Experimenter Board
' Oscillator  : 4MHz external crystal
' Keywords    : FOR NEXT
' Description : PICBASIC PRO program to blink 3 LEDS in sequence.
' 16F877
' Define LOADER_USED to allow use of the boot loader.
' This will not affect normal program operation.
'Define LOADER_USED 1

 i Var Byte  ' Define loop variable
LEDS Var PORTB  ' Alias PORTB to LEDS
  TRISB = %00000000  ' Set PORTB to all output
mainloop:
  LEDS = 1          ' First LED on
  Pause 500          ' Delay for .5 seconds
  For i = 1 To 2    ' Go through For..Next loop 2 times
    LEDS = LEDS << 1 ' Shift on LED one to left
    Pause 500        ' Delay for .5 seconds
  Next i
  Goto mainloop      ' Go back to mainloop and blink LED forever
  End

Viewing all 4787 articles
Browse latest View live