Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2016, 07:55:09 07:55


Login with username, password and session length


Pages: [1]
Print
Author Topic: PROBLEM WITH LCD AND 18F4550  (Read 4027 times)
0 Members and 1 Guest are viewing this topic.
jeanninemtv
Senior Member
****
Offline Offline

Posts: 315

Thank You
-Given: 57
-Receive: 25


« on: April 26, 2009, 10:40:58 10:40 »

Hello,
i begin to try a little with 18f4550 after a lot of time.... i wrote some code and it worked IN ISIS, but at the moment to burn it .... no sucess at all..
for example, i wrote it and it worked:

Code:
Device 18F4550
XTAL 20
ALL_DIGITAL true
Declare PLL_REQ = OFF
Declare LCD_RSPIN PORTB.3
Declare LCD_ENPIN PORTB.2
Declare LCD_DTPIN PORTD.4
Declare LCD_INTERFACE 4
Declare LCD_LINES 4
Declare LCD_COMMANDUS 4000' to 65535 microseconds (us).
'Time to wait (in microseconds) between commands sent to the LCD. If the DECLARE is not used in the program, then the default delay is 2000us (2ms).
Declare LCD_DATAUS 100' to 255 microseconds (us).
'Time to wait (in microseconds) between data sent to the LCD. If the DECLARE is not used in the program, then the default delay is 50us.


        Symbol TMR1IF = PIR1.0 ' TMR1 Overflow Interrupt Flag bit
        Symbol TMR2IF = PIR1.1 ' TMR2 to PR2 Match Interrupt Flag
        Symbol CCP1F = PIR1.2  ' CCP1 Interrupt Flag
        Symbol TXIF = PIR1.4   ' USART Transmit Interrupt Flag
        Symbol RCIF = PIR1.5   ' USART Receive Interrupt Flag
        Symbol CMIF = PIR1.6   ' Comparator Interrupt Flag
        Symbol EEIF = PIR1.7   ' EEPROM Write Operation Interrupt Flag
        Symbol RBIF = INTCON.0 ' RB Port Interrupt Flag
        Symbol INTF = INTCON.1 ' RB0 External Interrupt Flag
        Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
        Symbol RBIE = INTCON.3 ' RB Port Change Interrupt Enable
        Symbol INTE = INTCON.4 ' RB0 External Interrupt Enable
        Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
        Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
        Symbol GIE = INTCON.7  ' Global Interrupt Enable
        Symbol TMR1IE = PIE1.0 ' TMR1 Overflow Interrupt Enable
        Symbol TMR2IE = PIE1.1 ' TMR2 to PR2 Match Interrupt Enable
        Symbol CCP1IE = PIE1.2 ' CCP1 Interrupt Enable
        Symbol TXIE = PIE1.4   ' USART Transmit Interrupt Enable
        Symbol RCIE = PIE1.5   ' USART Receive Interrupt Enable
        Symbol CMIE = PIE1.6   ' Comparator Interrupt Enable
        Symbol EEIE = PIE1.7   ' EE Write Complete Interrupt Enable
       
Dim LOL As Byte
PORTB_PULLUPS TRUE
     
OVER_INTERRUPT:
LOL=0
TRISB=%11110011'$FF
TRISC=%11111111
TRISD=%00000000
DelayMS 250
Cls
ECRAN_PREUVE:
'             00000000011111111112       
'             12345678901234567890
Print At 1,1,"tps:00:00  tpp:00:00"
Print At 2,1,"#tr:00:00 dtps:00:00"
Print At 3,1,"tr/mn: 00000        "
Print At 4,1,"V: 00000   T: 000.00"
Set PORTD.1
NADA:

Print At 4,1,"V: 00000   T: 000.00"

DelayMS 250
 GoTo NADA
End


after that i thought to put to work portb change interrupts to manage 4 buttons, i have some ideas, but the problem is not that, i tried to put more code and lcd become crazy!  numbers are mixed and nothing understable is shown

NOTE, i disabled interrupts , i just tested if after press button rb0 next screen is shown a this moment, and no success!!



Code:
Device 18F4550
XTAL 20
Declare PLL_REQ = OFF
ALL_DIGITAL TRUE
Declare LCD_RSPIN PORTB.3
Declare LCD_ENPIN PORTB.2
Declare LCD_DTPIN PORTD.4
Declare LCD_LINES 4
ADIN_RES=10       ' --- resolucion
ADIN_STIME=100   ' --- tiempo de adquisicion
ADIN_TAD= frc    ' Allow 100us for charge time
        Symbol CCP1F = PIR1.2  ' CCP1 Interrupt Flag
        Symbol CMIF = PIR1.6   ' Comparator Interrupt Flag
        Symbol EEIF = PIR1.7   ' EEPROM Write Operation Interrupt Flag
        Symbol RBIF = INTCON.0 ' RB Port Interrupt Flag
        Symbol INTF = INTCON.1 ' RB0 External Interrupt Flag
        Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
        Symbol RBIE = INTCON.3 ' RB Port Change Interrupt Enable
        Symbol INTE = INTCON.4 ' RB0 External Interrupt Enable
        Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
        Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
        Symbol GIE = INTCON.7  ' Global Interrupt Enable
        Symbol TMR1IE = PIE1.0 ' TMR1 Overflow Interrupt Enable
        Symbol TMR2IE = PIE1.1 ' TMR2 to PR2 Match Interrupt Enable
        Symbol CCP1IE = PIE1.2 ' CCP1 Interrupt Enable
        Symbol ADIE = PIE1.6   ' Comparator Interrupt Enable
        Symbol EEIE = PIE1.7   ' EE Write Complete Interrupt Enable     
        Symbol TMR1IF = PIR1.0 ' TMR1 Overflow Interrupt Flag
        Symbol TMR2IF = PIR1.1 ' TMR2 to PR2 Match Interrupt Flag
        Symbol CCP1IF = PIR1.2 ' CCP1 Interrupt Flag
        Symbol SSPIF = PIR1.3  ' Synchronous Serial Port (SSP) Interrupt Flag
        Symbol TXIF = PIR1.4   ' USART Transmit Interrupt Flag
        Symbol RCIF = PIR1.5   ' USART Receive Interrupt Flag
        Symbol ADIF = PIR1.6   ' A/D Converter Interrupt Flag
        Symbol PSPIF = PIR1.7  ' Parallel Slave Port Read/Write Interrupt Flag
        Symbol relay_1 = PORTD.3 ' relai du marche-arrete general...
        Symbol relay_2 = PORTD.2 ' relai du klaxon...
       
Dim pos_cur As Byte
Dim raw As Word ' variable de prueba
Dim testi As Byte
Dim temp_moteur As Float
Dim tck As Byte ' contador para el tiempo base del reloj.
Dim tcks As Byte ' contador de base para cada segundo.. 200 en tmr2 me dio aprox 1 segundo
Dim min1 As Byte
Dim min2 As Byte
Dim sec1 As Byte
Dim sec2 As Byte
Dim ch0_val As Word
Dim ma As Bit
Dim dejapasse As Bit
Dim flag_buttonA As Bit
Dim flag_buttonB As Bit
Dim flag_klaxon As Bit
Dim flag_restore As Bit
Dim flag_tim1 As Bit
Dim tmp_portb As Byte
Dim m_total As Byte
Dim s_total As Byte
Dim m_partiel As Byte
Dim s_partiel As Byte
Dim m_dernier As Byte
Dim s_dernier As Byte
Dim m_best As Byte
Dim s_best As Byte
Dim f_tmp As Word
Dim freq_hall1 As word
Dim freq_hall2 As float
Dim nro_tours As Byte


PORTB_PULLUPS TRUE
    ON_INTERRUPT GoTo INTERRUPT_ROUTINE 'hardware interrupt
    GoTo OVER_INTERRUPT
    INTERRUPT_ROUTINE:
        Context SAVE                        ' Only needed for 16 bit devices
        If  INTF = 1 Then
        GoTo R_MARCHE_ARRETE
        EndIf       
        If  TMR2IF = 1 Then
        GoTo R_HORLOGE_PRINCIPAL
        EndIf
        If  RBIF = 1 Then
        GoTo R_BOUTONS
        EndIf
'********************************** interruption du timer... **************************       
R_HORLOGE_PRINCIPAL:
    TMR2=0
    PR2=190'5 '  200 da 1 segundo  50 da 250 mili
    tck=tck+1 
'
'aqui va rutina de display de vueltas!!
'   
If tck=100 Then
tcks=tcks +1
Toggle PORTD.1
    sec1=sec1+1
    If sec1=60 Then
        sec1=0
        min1=min1+1
    EndIf
    sec2=sec2+1       
    If flag_buttonB=1 Then
    nro_tours=nro_tours+1
    m_dernier=min2
    s_dernier=sec2
    sec2=0
    min2=0
    Clear  flag_buttonB
    EndIf
    If sec2=60 Then
        sec2=0
        min2=min2+1
    EndIf
        tck=0
EndIf
    TMR2IF=0
    Context Restore   
'++++++++++++++++++++++++++++++++++++++++++
R_MARCHE_ARRETE:
dejapasse=0
  If ma=0 Then
  ma=1
    relay_1=1
    Set RBIE
  Else
  ma=0
  relay_1=0
    Clear RBIE

  EndIf
      INTF=0
    Context Restore
R_BOUTONS:
    tmp_portb=PORTB
    tmp_portb=tmp_portb >> 4
    tmp_portb=tmp_portb & $0F
'***************** RUTINA DEL CLAXON, SOLO DURA CUANDO PRESIONAS *********************
If tmp_portb = %00001111 And testi=%00001101 Then
Clear flag_klaxon
Clear relay_2
EndIf
'*************************************************************************************
'boton A, comienza la cuenta....
If tmp_portb = %00000111 Then
    If flag_buttonA=0 Then
     Set flag_buttonA
     Set TMR2IE
    Else
     Clear  flag_buttonA
     Clear TMR2IE
    min1=0 : sec1=0 : min2=0 : sec2=0 : nro_tours=1
    EndIf
   testi=tmp_portb
EndIf
'*************************************************************************************
If tmp_portb = %00001011 Then
    If flag_buttonB=0 Then
     Set flag_buttonB
    EndIf
testi=tmp_portb
EndIf
If tmp_portb = %00001101 Then
Set flag_klaxon
Set relay_2
testi=tmp_portb
EndIf
If tmp_portb = %00001110 Then
Set flag_restore
testi=tmp_portb
EndIf
      RBIF=0 
    Context Restore
   
     
'********************************** PROGRAMA NORMAL      ... **************************       
OVER_INTERRUPT:
'etat initial des variables:
raw=0 :  tck=0  : ma=0 :  dejapasse=0
'CONFIG DU CH0 DU ConvertisseurAnalogue/Numerique:
    TRISA= $01 ' Setup PORTA.0 as an input
    ADCON1 = %10001110
'CONFIG OF PORTX


TRISB=$FF
TRISC=0
TRISD=0
TRISE=0
PORTB=0
PORTA=$FF
PORTC=0
PORTD=0
flag_buttonA=0
flag_buttonB=0
flag_klaxon=0
flag_restore=0
nro_tours=1
Cls
'   √©criture de caracteres dans le CGRAM du afficheur LCD.
'    Print $FE,$40,$1e,$1e,$10,$00,$1F,$15,$15,$00  '0 tpm
'    Print $FE,$48,$00,$0C,$12,$12,$0C,$00,$00,$00  '1 degrees
'    Print $FE,$50,$00,$0E,$1F,$1F,$1F,$0E,$00,$00  '2
'    Print $FE,$58,$00,$0E,$11,$11,$11,$0E,$00,$00  '3
'    Print $FE,$60,$08,$1D,$08,$09,$0C,$00,$1F,$00  '4
'    Print $FE,$68,$00,$0A,$0A,$0A,$00,$0E,$11,$00  '5
'    Print $FE,$70,$11,$1B,$15,$11,$11,$00,$1F,$00  '6 motor
'    Print $FE,$78,$1F,$00,$0E,$15,$1F,$15,$0E,$00  '7 ruedita

'CONFIG DES INTERRUPTS
Init:
'configuration de l'interrupt du timer2
    T2CON = %01111111 ' Set T2CON.2
    TMR2IF=0
    TMR2IE=0
    TMR2=0
    PR2=190'5
    INTCON=$C0        ' set GIE and PEIE bits %110000000
'configuration de l'interrupt du RB0/int
    INTE=1
    testi=$0F
main_loop:
    If ma=1 Then   
        GoTo screen_activate
    EndIf   
screen_disabled:
    If dejapasse=0 Then
        Cls
        dejapasse=1
    EndIf       
'             00000000011111111112       
'             12345678901234567890
Print At 1,3,"                    "
Print At 2,1," Press  M/A         "
Print At 3,1,"                    "
Print At 4,4,"                    "
raw=0  :  tck=0  :  tcks=0   :  min1=0  :  sec1=0



lala:

delayms 2000

''*---------------------------------------------

                     '1234567890   123  456789    0
Print At 1,1," :      t ","  ","      "," C" ' Outp ut
'             1  23456789   10 12  13 14 15 16 17 18 19 20
        Print At 2,1," :      t","   " '',$3,$3,$3,$3,$3,$3,$3,$3
        '             12345678901234567890 
        Print At 3,1,"tp:  :    tt:  :"
        Print At 4,1,"tour:     td:  :"   


''*---------------------------------------------
goto lala

GoTo main_loop   

screen_activate:
    If dejapasse=1 Then
        GoTo loop_001
    EndIf   
screen_main:
Cls
    dejapasse=1
'                 00000000011111111112       
'                 12345678901234567890
'    Print At 1,1,"tps:00:00  tpp:00:00"
'    Print At 2,1,"#tr:    dtps:00:00"
'    Print At 3,1,"  RPM : 00000"
'    Print At 4,1,"V: 00000   T:"

                     ' 1  2345678  9   0123  4  5  6  7  8  90
Print At 1,1,":      t","  ","       "," C" ' Outp ut
'             1  23456789   10 12  13 14 15 16 17 18 19 20
        Print At 2,1,":      t","  "',$3,$3,$3,$3,$3,$3,$3,$3
        '             12345678901234567890 
        Print At 3,1,"tp:  :    tt:  :"
        Print At 4,1,"tour:     td:  :"   

loop_001:
nop
NADA:

'***************** ACONDICIONAMIENTO DEL SENSOR DE TEMPERATURA ***********************
raw=ADIn 0
raw= raw * 5
temp_moteur = raw/ 1023 'mV
If temp_moteur > 2.6 Then
temp_moteur= temp_moteur - 2.368
Else
temp_moteur= temp_moteur - 2.315
EndIf
temp_moteur= temp_moteur * 140.5'255 / 1.815
'*************************************************************************************
f_tmp= Counter PORTC.1 , 500
freq_hall1 = f_tmp * 120
f_tmp= Counter PORTC.2 , 450
DelayMS 35
freq_hall2 = f_tmp * 1.26
Print At 1,3,DEC4 freq_hall1
Print At 2,3,DEC1 freq_hall2
'Cursor 4,14
' If temp_moteur < 10 Then
'  Print "00"',DEC1 temp_moteur
'  GoTo suiv2
' EndIf
' If temp_moteur < 100 Then
'  Print "0"',DEC1 temp_moteur
'  GoTo suiv2
' EndIf   'If temp_moteur > 99 Then   'Print At 4,14',DEC1 temp_moteur  'EndIf
'suiv2:
' Print DEC1 temp_moteur
'AFFICHAGE DES PARAMETRES --> TEMPS....
        Print At 3,4,DEC2 min2
        Print At 3,7,DEC2 sec2
        Print At 3,14,DEC2 min1
        Print At 3,17,DEC2 sec1
        Print At 4,6,DEC2 nro_tours
        Print At 4,14,DEC2 m_dernier
        Print At 4,17,DEC2 s_dernier       

'Print At 4,5,BIN4 testi' prueba de status de los botones de control
'colocar logica del sistema cronometro aqui....

GoTo main_loop
End



I THINK ITS SOMETHING WRONG WITH FUSES, I REALLY DONT KNOW I AM DELETTING PARTS TO VIEW IF IT WORKS AND NOTHING HAPPEN...

Posted on: April 26, 2009, 10:38:56 10:38 - Automerged

BTW,  i'm using pds 3.2.5.5  integrated with mplab prior to use icd2 programmer

Logged
SONSiVRi
Administrator
Hero Member
*****
Offline Offline

Posts: 1446

Thank You
-Given: 69
-Receive: 380



WWW
« Reply #1 on: April 26, 2009, 11:21:28 11:21 »

It's not looks like those command works for you, but worths to try.
Code:
DECLARE LCD_COMMANDUS
DECLARE LCD_DATAUS
Logged

- Houston, we have a problem.
Biggles
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 14
-Receive: 22



« Reply #2 on: April 26, 2009, 01:02:30 13:02 »

Hello,
i begin to try a little with 18f4550 after a lot of time.... i wrote some code and it worked IN ISIS, but at the moment to burn it .... no sucess at all..
for example, i wrote it and it worked:


Sorry, this is not clear to me..  are you saying the first code segment worked in ISIS, but does not work when you program the part?


For the second code, I would try change the LCD RS and EN pins to PORT D, or another port, not PORT B.


Logged

Man who act in haste, repent at leisure.
jeanninemtv
Senior Member
****
Offline Offline

Posts: 315

Thank You
-Given: 57
-Receive: 25


« Reply #3 on: April 26, 2009, 01:21:22 13:21 »

yes, it worked on isis, but i programmed it and became the hell...

BTW  any suggest about fuse configuration?
- in the meantime i will re write a little and clean out the code source ...
Logged
TomJackson69
V.I.P
Active Member
*****
Offline Offline

Posts: 221

Thank You
-Given: 23
-Receive: 63


« Reply #4 on: April 27, 2009, 01:31:28 01:31 »

jeanninemtv,

Usually when your program works in ISIS but not on the real hardware, there may be timing problem. In this case, you said it's works on ISIS but display on LCD crazy than give some more delay on the write CMD and write CHAR routine. I don't have basic compiler so I don't know what delay in the build in function.

On top of your program I see you declare some delay variables. Let change those value to see if its work for you. I would suggest you do it on the ISIS. Change the delay value to a smaller value until ISIS will not display. If that is the case, change the delay value to twice the old value and try it on the real hardware.

Try to change your lines:
Declare LCD_COMMANDUS 4000' to 65535 microseconds (us).
'Time to wait (in microseconds) between commands sent to the LCD. If the DECLARE is not used in the program, then the default delay is 2000us (2ms).
Declare LCD_DATAUS 100' to 255 microseconds (us).
'Time to wait (in microseconds) between data sent to the LCD. If the DECLARE is not used in the program, then the default delay is 50us.

Tom
Logged

Con Rong Chau Tien
Biggles
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 14
-Receive: 22



« Reply #5 on: April 28, 2009, 01:47:36 01:47 »

1) Are you using Proton?  If so, get the Fuse Configurator plugin. It is very useful.

2) Are you setting OSCCON correctly?

(here is example for 8Mhz, check datasheet for 20Mhz)

OSCCON = %01110000      

or

OSCCON.6 = 1  ' 8Mhz
OSCCON.5 = 1  ' 8Mhz
OSCCON.4 = 1  ' 8Mhz



3) Do not forget the power of simple LED flash. Get an LED to flash at 1Hz or longer and check timing with stop watch. I do this with every new microcontroller I use for the first time.
Burning a real chip is very different from ISIS.

Logged

Man who act in haste, repent at leisure.
jeanninemtv
Senior Member
****
Offline Offline

Posts: 315

Thank You
-Given: 57
-Receive: 25


« Reply #6 on: April 28, 2009, 07:10:02 07:10 »

i'm still confused...

i want to work the circuit to cronomet and measur some extra variables, and furtherly send them via usb to a laptop.  but... if i cant make work the simple stuff on real world.... Sad
Logged
Biggles
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 14
-Receive: 22



« Reply #7 on: April 28, 2009, 11:03:55 11:03 »

In my opinion, there is not simple stuff with anything when it comes to microcontrollers. Either you know the information, or you do not.

It sounds like you have some timing isues and maybe hardware setup issues. Use the simle LED flash to check your timing and hardware configuration. Maybe also add button press to check inputs and make LED's change. Yes, I knwo it sounds like child code, but it is a good way to eliminate hardware and setup issues, so you can concentrate on your super high tech usb many variables project.


One other thing I do now for many years since first flash part came out from microchip, is I always ERASE flash part before writing code.
Logged

Man who act in haste, repent at leisure.
jeanninemtv
Senior Member
****
Offline Offline

Posts: 315

Thank You
-Given: 57
-Receive: 25


« Reply #8 on: April 28, 2009, 11:57:16 11:57 »

LED BLINK WORKED FINE ON PICDEM BOARD

BUT STILL NO RESULTS AWAY OF LCD CRAP AFTER PUTTING 2ND MESSAGE AND LOOP

I CAN SHOW ONE MESSAGE BUT IT BECAME SH*T IF I PUT LOOP AND OTHER MESSAGE

STILL DEPRESSED ..
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #9 on: April 28, 2009, 11:43:37 23:43 »

In your code where are you setting your fuse configuration?, and can your programmer set them?
have you looked at the data sheet for 18F4550?
have you seen the P18F4550.LPB?

here is the list of things you need to set up. 14 locations. 
CONFIG1L        EQU  0x300000
CONFIG1H        EQU  0x300001
CONFIG2L        EQU  0x300002
CONFIG2H        EQU  0x300003
CONFIG3H        EQU  0x300005
CONFIG4L        EQU  0x300006
CONFIG5L        EQU  0x300008
CONFIG5H        EQU  0x300009
CONFIG6L        EQU  0x30000A
CONFIG6H        EQU  0x30000B
CONFIG7L        EQU  0x30000C
CONFIG7H        EQU  0x30000D

When I start a project for a new to device I set up a test rig, a led port monitor, an input port, and a LCD port.
then when I see this working with a test.hex before comiting myself to write code for the project.
(I set fuse config up for the chip I'm using before writing any code, and if its a new chip to me, Then I do a small flash a led or other small project, just to get a feel for the device
http://www.sonsivri.com/forum/index.php?topic=20266.msg71217#msg71217 is a case of this, I posted so as to shop how to set up config of fuses for the 16F676  if you have used this chip then you would know it is a pain to setup)

A note on your code:   it don't even follow the samples in proton help files.
here is the setup for LCD.    note no Declare  before setting the port and pin for the LCD.
Code:
LCD_DTPIN = PORTD.4            ' LCD data port attached to PORTD    not >>   Declare LCD_DTPIN = PORTD.4
LCD_RSPIN = PORTE.0            ' LCD RS pin attached to PORTE.0
LCD_ENPIN = PORTE.1            ' LCD EN pin attached to PORTE.1
LCD_INTERFACE = 4               ' 4-bit Interface
LCD_LINES = 2                      ' 2 line LCD
LCD_TYPE = ALPHANUMERIC    ' Use an Hitachi alphanumeric LCD there are other codes for this option too. 0...3
« Last Edit: April 28, 2009, 11:47:11 23:47 by pickit2 » Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
jeanninemtv
Senior Member
****
Offline Offline

Posts: 315

Thank You
-Given: 57
-Receive: 25


« Reply #10 on: April 29, 2009, 03:38:42 03:38 »

for blinking led in the picdem board i didn't changed anithing, neither fuses on proton neither config bit in the corresponding mplab icd2 window - i'm afraid of that checkbox....-  and it worked. then i passed it to the lcd backlit transistor pin and it worked too. but after putting the other code...  i will begin test modes monday because i have no time to go to "garage " to work with all the stuff.  it's still the middle of a busy week.  only time to play with laptop and vsm stuff...

bw i 'm still using 7.2 version for tests. because 7.4 crash out after X minutes - 15, 20, i don't know- and 7.5 version, simply i haven't tested yet...

ok let's start again, i will rewrite my code and ... i will test all after 1st may

Code:
' REV 00: * RE ECRITURE DU PROGR.
'         * BOUCLE SIMPLE TEST AFFICHEUR
Device 18F4550 ' PIC: 18F4550 I/P
XTAL 20 ' FREQUENCE BASE DES TIMINGS...

Dim BLINK1 As Bit
' espace declarations 1

' espace declarations variables


ALL_DIGITAL     = TRUE ' no analog pins until configuration. 

LCD_TYPE        = ALPHA   'ALPHANUMERIC LCD
LCD_ENPIN       = PORTB.2
LCD_RSPIN       = PORTB.3
LCD_DTPIN       = PORTD.4
LCD_INTERFACE   = 4               ' 4-bit Interface
LCD_LINES 4
'--------------------------------------------------------
Cls
DelayMS 2000
Cls
'--------------------------------------------------------
message1_blinkin:

BLINK1=0    ' initialize variable for message1 blink
             '12345678901234567890'
Print At 1,1,"    rev 00          "
Print At 2,1,"   TO START ENGINE  "
Print At 3,1,"    PRESS           "

LOOP:
    If  BLINK1=0 Then
        BLINK1=1
        Print At 4,1,"            M/A     "
    Else
        BLINK1=0
        Print At 4,1,"   BUTTON           "
    EndIf

    DelayMS 500

GoTo LOOP

'------------------------------------------------------

best regards


Posted on: April 29, 2009, 03:14:44 03:14 - Automerged

preparing set of tests. more order i think will be my solution...

Code:
' REV 01: * interruption BITS inclus.
'         * bits osccon inclus                       
'         * pas d'interrupts pour le moment.

Device 18F4550 ' PIC: 18F4550 I/P
XTAL 20 ' FREQUENCE BASE DES TIMINGS...
'-------------------------------------------------------

' espace declarations variables: bits
Dim BLINK1      As Bit
Dim NOBUTTONS   As Bit
' espace declarations variables: bytes
Dim I           As Byte
' espace declarations variables: words
' espace declarations variables: dwords
' espace declarations variables: floats

' espace declarations variables: my alias


' espace declarations variables: system alias
        Symbol CCP1F = PIR1.2  ' CCP1 Interrupt Flag
        Symbol CMIF = PIR1.6   ' Comparator Interrupt Flag
        Symbol EEIF = PIR1.7   ' EEPROM Write Operation Interrupt Flag
        Symbol RBIF = INTCON.0 ' RB Port Interrupt Flag
        Symbol INTF = INTCON.1 ' RB0 External Interrupt Flag
        Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
        Symbol RBIE = INTCON.3 ' RB Port Change Interrupt Enable
        Symbol INTE = INTCON.4 ' RB0 External Interrupt Enable
        Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
        Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
        Symbol GIE = INTCON.7  ' Global Interrupt Enable
        Symbol TMR1IE = PIE1.0 ' TMR1 Overflow Interrupt Enable
        Symbol TMR2IE = PIE1.1 ' TMR2 to PR2 Match Interrupt Enable
        Symbol CCP1IE = PIE1.2 ' CCP1 Interrupt Enable
        Symbol ADIE = PIE1.6   ' Comparator Interrupt Enable
        Symbol EEIE = PIE1.7   ' EE Write Complete Interrupt Enable     
        Symbol TMR1IF = PIR1.0 ' TMR1 Overflow Interrupt Flag
        Symbol TMR2IF = PIR1.1 ' TMR2 to PR2 Match Interrupt Flag
        Symbol CCP1IF = PIR1.2 ' CCP1 Interrupt Flag
        Symbol SSPIF = PIR1.3  ' Synchronous Serial Port (SSP) Interrupt Flag
        Symbol TXIF = PIR1.4   ' USART Transmit Interrupt Flag
        Symbol RCIF = PIR1.5   ' USART Receive Interrupt Flag
        Symbol ADIF = PIR1.6   ' A/D Converter Interrupt Flag
        Symbol PSPIF = PIR1.7  ' Parallel Slave Port Read/Write Interrupt Flag
'................................................................................
ALL_DIGITAL     = TRUE ' no analog pins until configuration. 

LCD_TYPE        = ALPHA   'ALPHANUMERIC LCD
LCD_ENPIN       = PORTB.2
LCD_RSPIN       = PORTB.3
LCD_DTPIN       = PORTD.4
LCD_INTERFACE   = 4               ' 4-bit Interface
LCD_LINES 4
'--------------------------------------------------------
' code starts here
'--------------------------------------------------------
Cls
DelayMS 2000
Cls
'---------------------------------- ----------------------
message1_blinkin:

BLINK1=0    ' initialize variable for message1 blink
             '12345678901234567890'
Print At 1,1,"    rev 01          "
Print At 2,1,"   TO START ENGINE  "
Print At 3,1,"    PRESS           "

NOBUTTONS   = 1 ' AT THE BEGINNING, NO BUTTON PRESSED.

LOOP:
    If  BLINK1      = 0 Then
        BLINK1      = 1
        Print At 4,1,"            M/A     "
    Else
        BLINK1=0
        Print At 4,1,"   BUTTON           "
    EndIf

For I=1 To 500
    DelayMS 100
    If  NOBUTTONS   = 0 Then    Break
Next

    If  NOBUTTONS    = 0 Then
        GoTo MESSAGE2
    EndIf

GoTo LOOP
MESSAGE2:
Cls
Print At 1,1,"BUTTONS PRESSED"

LOOP1:
DelayMS 500
GoTo LOOP1
'------------------------------------------------------





before sleep a little bit...

Code:
' REV 02: * interruption BITS inclus.
'         * bits osccon inclus                       
'         * rb0 change le message.

Device 18F4550 ' PIC: 18F4550 I/P
XTAL 20 ' FREQUENCE BASE DES TIMINGS...
'-------------------------------------------------------
ON_INTERRUPT GoTo INTERRUPT_ROUTINE 'hardware interrupt

' espace declarations variables: bits
Dim BLINK1      As Bit
Dim NOBUTTON0   As Bit
' espace declarations variables: bytes
Dim I           As Byte
' espace declarations variables: words
' espace declarations variables: dwords
' espace declarations variables: floats

' espace declarations variables: my alias


' espace declarations variables: system alias
        Symbol CCP1F = PIR1.2  ' CCP1 Interrupt Flag
        Symbol CMIF = PIR1.6   ' Comparator Interrupt Flag
        Symbol EEIF = PIR1.7   ' EEPROM Write Operation Interrupt Flag
        Symbol RBIF = INTCON.0 ' RB Port Interrupt Flag
        Symbol INTF = INTCON.1 ' RB0 External Interrupt Flag
        Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
        Symbol RBIE = INTCON.3 ' RB Port Change Interrupt Enable
        Symbol INTE = INTCON.4 ' RB0 External Interrupt Enable
        Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
        Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
        Symbol GIE = INTCON.7  ' Global Interrupt Enable
        Symbol TMR1IE = PIE1.0 ' TMR1 Overflow Interrupt Enable
        Symbol TMR2IE = PIE1.1 ' TMR2 to PR2 Match Interrupt Enable
        Symbol CCP1IE = PIE1.2 ' CCP1 Interrupt Enable
        Symbol ADIE = PIE1.6   ' Comparator Interrupt Enable
        Symbol EEIE = PIE1.7   ' EE Write Complete Interrupt Enable     
        Symbol TMR1IF = PIR1.0 ' TMR1 Overflow Interrupt Flag
        Symbol TMR2IF = PIR1.1 ' TMR2 to PR2 Match Interrupt Flag
        Symbol CCP1IF = PIR1.2 ' CCP1 Interrupt Flag
        Symbol SSPIF = PIR1.3  ' Synchronous Serial Port (SSP) Interrupt Flag
        Symbol TXIF = PIR1.4   ' USART Transmit Interrupt Flag
        Symbol RCIF = PIR1.5   ' USART Receive Interrupt Flag
        Symbol ADIF = PIR1.6   ' A/D Converter Interrupt Flag
        Symbol PSPIF = PIR1.7  ' Parallel Slave Port Read/Write Interrupt Flag     
'................................................................................
ALL_DIGITAL     = TRUE ' no analog pins until configuration. 
PORTB_PULLUPS   = TRUE

LCD_TYPE        = ALPHA   'ALPHANUMERIC LCD
LCD_ENPIN       = PORTB.2
LCD_RSPIN       = PORTB.3
LCD_DTPIN       = PORTD.4
LCD_INTERFACE   = 4               ' 4-bit Interface
LCD_LINES 4
'--------------------------------------------------------

GoTo OVER_INTERRUPT
INTERRUPT_ROUTINE:
    Context SAVE                        ' Only needed for 16 bit devices
    If  INTF = 1 Then
        GoTo START_STOP
    EndIf       

START_STOP:
  If    NOBUTTON0   = 0 Then
        NOBUTTON0   = 1
  '  Set RBIE
  Else
        NOBUTTON0   = 0
  '  Clear RBIE
  EndIf
      INTF=0
  Context Restore
'-------------------------------------------------------------------------------       
' code starts here
'--------------------------------------------------------
OVER_INTERRUPT:

Cls
DelayMS 2000
Cls
'---------------------------------- ----------------------
message1_blinkin:

BLINK1=0    ' initialize variable for message1 blink
             '12345678901234567890'
Print At 1,1,"    rev 02          "
Print At 2,1,"   TO START ENGINE  "
Print At 3,1,"    PRESS           "

INTE    = 1  ' RB0 INTERRUPT ENABLED
GIE     = 1  ' GIE ENABLED

NOBUTTON0   = 1 ' AT THE BEGINNING, NO BUTTON PRESSED.

LOOP:
    If  BLINK1      = 0 Then
        BLINK1      = 1
        Print At 4,1,"            M/A     "
    Else
        BLINK1=0
        Print At 4,1,"   BUTTON           "
    EndIf

For I=1 To 500
    DelayMS 100
    If  NOBUTTON0    = 0 Then    Break
Next

    If  NOBUTTON0    = 0 Then
        GoTo MESSAGE2
    EndIf

GoTo LOOP
MESSAGE2:
Cls
Print At 1,1,"BUTTONS PRESSED"

LOOP1:
DelayMS 500
GoTo LOOP1
'------------------------------------------------------
« Last Edit: April 29, 2009, 04:10:45 04:10 by jeanninemtv » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #11 on: April 29, 2009, 12:25:34 12:25 »

I still think you still have a problem with fuse settings, see this topic
http://www.picbasic.org/forum/showthread.php?t=4826&highlight=18F4550+config
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC