lcgamboa / picsimlab

PICsimLab - Programmable IC Simulator Laboratory
GNU General Public License v2.0
455 stars 88 forks source link

Setting Port Directions / Possible Banksel Issue #2

Closed caroper closed 5 years ago

caroper commented 5 years ago

This code should show D0 and B7 Lit on Board 4 - PICGenios ;Start of the main program ;test dir ; ;PortD = 0b00000001 ; Initial LED Pattern movlw 1 movwf PORTD ;PortB = 0b10000000 ; Initial LED Pattern movlw 128 movwf PORTB ;Dir PortD Out ; All PortD Pins as Outputs banksel TRISD clrf TRISD ;Dir PortB Out ; All PortB Pins as Outputs clrf TRISB

However, when clrf TRISB executes all of the PortD LED's light.

Regards, Chris Roper

caroper commented 5 years ago

This Code Works in PICSimLab:

;Start of the main program ;test dir ; ;PortD = 0b00000001 ; Initial LED Pattern movlw 1 movwf PORTD ;Dir PortD Out ; All PortD Pins as Outputs banksel TRISD clrf TRISD ;PortB = 0b10000000 ; Initial LED Pattern movlw 128 banksel PORTB movwf PORTB ;Dir PortB Out ; All PortB Pins as Outputs banksel TRISB clrf TRISB

Both versions work on physical hardware.

Regards, Chris Roper

lcgamboa commented 5 years ago

Probably the problem is in picsim and not in picsimlab. What microcontroller you used in the simulation, PIC16FXXX or PIC18FXXX?

caroper commented 5 years ago

I tried both, but the most extensive testing was on a 16f877a as I had that one on a Dev Board for comparison to the sim.

I am very impressed with PICSimLab, excellent work, and I was hoping to use it to develop several beginner lessons using Great Cow BASIC as the compiler. The two together would make an excellent way for beginners, particularly in third world countries, to try out Microcontrollers without having to invest in expensive equipment and compilers. I am South African and the cost is the major barrier in most schools and for hobbyists.

Regards Chris

lcgamboa commented 5 years ago

Hello Chris,

this problem is really a bug in picsim in relation to the latch of the ports. Configuring the value of TRIS before using the PORT everything works without problems, putting the value in LATCH and configuring TRIS as an output don't work in picsim as it should. I'll try to fix the problem in picsim. I will close the topic because the problem is in another project.

Thank you for this return.

caroper commented 5 years ago

Thanks, Appreciated

On Tue, 30 Oct 2018 at 16:03, lcgamboa notifications@github.com wrote:

Closed #2 https://github.com/lcgamboa/picsimlab/issues/2.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#event-1935143148, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUUefwzXQFSkzBH5PTyTacNwVYjIxCxks5uqFwygaJpZM4X_Hwr .

lcgamboa commented 5 years ago

The bug was fixed in picsim project: https://github.com/lcgamboa/picsim/commit/2b60c7f1d848e96d6188737b0ece3b5a550e528c

caroper commented 5 years ago

Thanks,

I found another issue related to I2C but thought it may be a related issue so have been using software I2C in the interim. Is there a way I can update PICSimLab or do I need to wait for a New general release?

Thanks for taking the time to address the issue.

Regards Chris

On Tue, 30 Oct 2018 at 21:43, lcgamboa notifications@github.com wrote:

The bug was fixed in picsim project: lcgamboa/picsim@2b60c7f https://github.com/lcgamboa/picsim/commit/2b60c7f1d848e96d6188737b0ece3b5a550e528c

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#issuecomment-434442093, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUUeT7zjSXiSJjbfUDgxxsyozCTeIn_ks5uqKv4gaJpZM4X_Hwr .

lcgamboa commented 5 years ago

Chris,

try the test version https://www.dropbox.com/sh/rz1fm8b8zev5jzz/AABrk_D24Z24gkc9wNeAAeraa?dl=0 Any problem write to me.

Best regards.

Luis Claudio Gambôa Lopes

Em terça-feira, 30 de outubro de 2018 17:06:28 BRT, caroper <notifications@github.com> escreveu:  

Thanks,

I found another issue related to I2C but thought it may be a related issue so have been using software I2C in the interim. Is there a way I can update PICSimLab or do I need to wait for a New general release?

Thanks for taking the time to address the issue.

Regards Chris

On Tue, 30 Oct 2018 at 21:43, lcgamboa notifications@github.com wrote:

The bug was fixed in picsim project: lcgamboa/picsim@2b60c7f https://github.com/lcgamboa/picsim/commit/2b60c7f1d848e96d6188737b0ece3b5a550e528c

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#issuecomment-434442093, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUUeT7zjSXiSJjbfUDgxxsyozCTeIn_ks5uqKv4gaJpZM4X_Hwr .

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub, or mute the thread.

caroper commented 5 years ago

Thanks Luis,

Much appreciated, Downloading as i type this.

Cheers Chris

On Tue, 30 Oct 2018 at 22:59, lcgamboa notifications@github.com wrote:

Chris,

try the test version https://www.dropbox.com/sh/rz1fm8b8zev5jzz/AABrk_D24Z24gkc9wNeAAeraa?dl=0 Any problem write to me.

Best regards.

Luis Claudio Gambôa Lopes

Em terça-feira, 30 de outubro de 2018 17:06:28 BRT, caroper < notifications@github.com> escreveu:

Thanks,

I found another issue related to I2C but thought it may be a related issue so have been using software I2C in the interim. Is there a way I can update PICSimLab or do I need to wait for a New general release?

Thanks for taking the time to address the issue.

Regards Chris

On Tue, 30 Oct 2018 at 21:43, lcgamboa notifications@github.com wrote:

The bug was fixed in picsim project: lcgamboa/picsim@2b60c7f < https://github.com/lcgamboa/picsim/commit/2b60c7f1d848e96d6188737b0ece3b5a550e528c

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#issuecomment-434442093, or mute the thread < https://github.com/notifications/unsubscribe-auth/AFUUeT7zjSXiSJjbfUDgxxsyozCTeIn_ks5uqKv4gaJpZM4X_Hwr

.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#issuecomment-434465794, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUUeb8n3B8FT58yH5aW3-m7iMmRj-Paks5uqL2mgaJpZM4X_Hwr .

caroper commented 5 years ago

It works

Out of interest here is the code used: ' ' The example program below was written with the Open Source ' Great Cow BASIC compiler (http://www.gcbasic.com/) ' ' it Rotates the LED's on Port B and D ' of the PICSimLab Board 4 - PICGenios. ' (https://sourceforge.net/projects/picsim/) ' ' Program example: Demo2c_Both_LED_Ports.gcb ' ' Board: PICSimLab Board 4 - PICGenios ' MCU: PIC16F877a ' Clock: 8MHz ' Compiler: GCBASIC - (http://www.gcbasic.com/) ' Author: C.A.Roper - 2018 ' Config:

Chip 16f877a, 16 ; Target Device and Clock Speed

option Explicit ; Variables must be pre declared

' PortB = 0b10000000 ; Initial LED Pattern PortD = 0b00000001 ; Initial LED Pattern

Dir PortB Out ; All PortB Pins as Outputs Dir PortD Out ; All PortD Pins as Outputs

Main:

Do wait 500 ms Rotate PortD Left Simple Rotate PortB Right Simple Loop

End

It is nearly midnight here but I look forward to exploring more in the morning.

Regards and thanks again, Chris

On Tue, 30 Oct 2018 at 22:59, lcgamboa notifications@github.com wrote:

Chris,

try the test version https://www.dropbox.com/sh/rz1fm8b8zev5jzz/AABrk_D24Z24gkc9wNeAAeraa?dl=0 Any problem write to me.

Best regards.

Luis Claudio Gambôa Lopes

Em terça-feira, 30 de outubro de 2018 17:06:28 BRT, caroper < notifications@github.com> escreveu:

Thanks,

I found another issue related to I2C but thought it may be a related issue so have been using software I2C in the interim. Is there a way I can update PICSimLab or do I need to wait for a New general release?

Thanks for taking the time to address the issue.

Regards Chris

On Tue, 30 Oct 2018 at 21:43, lcgamboa notifications@github.com wrote:

The bug was fixed in picsim project: lcgamboa/picsim@2b60c7f < https://github.com/lcgamboa/picsim/commit/2b60c7f1d848e96d6188737b0ece3b5a550e528c

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#issuecomment-434442093, or mute the thread < https://github.com/notifications/unsubscribe-auth/AFUUeT7zjSXiSJjbfUDgxxsyozCTeIn_ks5uqKv4gaJpZM4X_Hwr

.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lcgamboa/picsimlab/issues/2#issuecomment-434465794, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUUeb8n3B8FT58yH5aW3-m7iMmRj-Paks5uqL2mgaJpZM4X_Hwr .