also I'm having a hard time editing my text on the rich texteditor blinking out randomly even on my laptop and those are copied from a code generated result
(06-25-2015, 05:51 AM)Segolia Wrote: [ -> ]It's just a convenience function. You gotta do it yourself in assembly which means busy-waiting (throw the processor into a fixed length loop). To work out the time you need to bust out the data sheet and find out the clock speed, work out the number of cycles your loop takes and do some magic (my minds a bit hazy on the specifics atm).
As for sending things serially? Does your device have something like UART? You should use that.
no...it's a PIC16F877a on a SK40C board with a 4MHz clock, I'm trying to have 5 LED light up in one direction and when a switch is pressed the LED lights up in the opposite direction,
so everything should be in he assembly code, which I have trouble with
Using a clock of some kind is probably preferable to busy-waiting. Is there a configurable clock (like, with a register?). I'd do it something like this:
-Configure clock to desired delay (eg. 500ms)
-Store LED bitmask in some byte in memory or use a register (like "2_00000" where each digit corresponds to an LED in the sequence)
-Initialise the bitmask with some value (eg. "2_00001")
-On clock interrupt, circular shift right, use bitmask to determine which LED to light up and send a signal to the corresponding pin (alternatively you could save some hassle, say if your device has ports with multiple pins which share a single data register, just store the LED bitmask in the data register and shift that, then just hook LEDs up to appropriate pins)
-Write an interrupt handler for the button press, simply make it toggle the direction of the shift which happens on the clock interrupt.
(06-25-2015, 06:05 AM)Jim_Clonk Wrote: [ -> ]Looks nice. You can be our architect then? Just please not taskbar next time xd
Everyone should be able to build.
Not just one person.
I'm pretty sure everyone will be able to build. but if someone how doesn't know what they are doing tries to build something onto the really fancy building someone made, that's probably not going to look very good.
So what I meant was: the people who can make things look good, should be the ones to do so.
(06-25-2015, 06:06 AM)Battle Bee Wrote: [ -> ]Everyone should be able to build.
Not just one person.
I'm pretty sure everyone will be able to build. but if someone how doesn't know what they are doing tries to build something onto the really fancy building someone made, that's probably not going to look very good.
So what I meant was: the people who can make things look good, should be the ones to do so.
Ahh, I don't wanna be the ONLY builder. It's just my primary focus.
(06-25-2015, 05:56 AM)SCN-3_NULL Wrote: [ -> ]no...it's a PIC16F877a on a SK40C board with a 4MHz clock, I'm trying to have 5 LED light up in one direction and when a switch is pressed the LED lights up in the opposite direction,
so everything should be in he assembly code, which I have trouble with
Using a clock of some kind is probably preferable to busy-waiting. Is there a configurable clock (like, with a register?). I'd do it something like this:
-Configure clock to desired delay (eg. 500ms)
-Store LED bitmask in some byte in memory or use a register (like "2_00000" where each digit corresponds to an LED in the sequence)
-Initialise the bitmask with some value (eg. "2_00001")
-On clock interrupt, circular shift right, use bitmask to determine which LED to light up and send a signal to the corresponding pin (alternatively you could save some hassle, say if your device has ports with multiple pins which share a single data register, just store the LED bitmask in the data register and shift that, then just hook LEDs up to appropriate pins)
-Write an interrupt handler for the button press, simply make it toggle the direction of the shift which happens on the clock interrupt.
I'm not sure about the configurable clock but I do finf TMR1,TMR2 and a few TRM in the special registers, are those what I'm looking for?
and yes the device has ports, I'm planning on assembling them like this, but with 5LEDs and 4MHz clock
And a code example would be really useful, dont see these in my slides, will put those in the comments just for reminder.
and this is the SK40C board
all I have to do is to pin in the leds on the ports on the sides where the chip is installed
(06-25-2015, 06:06 AM)Battle Bee Wrote: [ -> ]Everyone should be able to build.
Not just one person.
(06-25-2015, 06:14 AM)Jim_Clonk Wrote: [ -> ]I'm pretty sure everyone will be able to build. but if someone how doesn't know what they are doing tries to build something onto the really fancy building someone made, that's probably not going to look very good.
So what I meant was: the people who can make things look good, should be the ones to do so.
Ahh, I don't wanna be the ONLY builder. It's just my primary focus.
I might take architect as a secondary focus. I can build kind of nice looking things.
(06-25-2015, 06:08 AM)Segolia Wrote: [ -> ]Using a clock of some kind is probably preferable to busy-waiting. Is there a configurable clock (like, with a register?). I'd do it something like this:
-Configure clock to desired delay (eg. 500ms)
-Store LED bitmask in some byte in memory or use a register (like "2_00000" where each digit corresponds to an LED in the sequence)
-Initialise the bitmask with some value (eg. "2_00001")
-On clock interrupt, circular shift right, use bitmask to determine which LED to light up and send a signal to the corresponding pin (alternatively you could save some hassle, say if your device has ports with multiple pins which share a single data register, just store the LED bitmask in the data register and shift that, then just hook LEDs up to appropriate pins)
-Write an interrupt handler for the button press, simply make it toggle the direction of the shift which happens on the clock interrupt.
I'm not sure about the configurable clock but I do finf TMR1,TMR2 and a few TRM in the special registers, are those what I'm looking for?
and yes the device has ports, I'm planning on assembling them like this, but with 5LEDs and 4MHz clock
And a code example would be really useful, dont see these in my slides, will put those in the comments just for reminder.
I can't give you a code example easily. I'd have to read through the datasheet for your device to even work out pinouts and registers properly. Not to mention I'm a bit rusty and I've never worked with PIC (I learned assembly with an ARM architecture).
It should be pretty straightforward, you know how to write interrupt handlers right? psuedocode would look something like
Quote:Main:
-configure clock registers (for desired delay)
-configure GPIO pins/ports/whatever for LED
-Store LED bitmask (0x01) in memory or register
-Store Direction flag/bit (0x0) in memory or register
-enable port/pins
-enable clock
Clock interrupt handler:
-read LED bitmask into register
-Clear all current LED pins
-Perform some logic to write to appropriate pin (eg. write value of LED bitmask AND 2_00000001 to LED 1, bitmask AND 2_00000010 to LED 2 etc.)
-read direction flag/bit
-Circular shift (aka rotate no carry) either left or right based on value of direction bit (eg. left if 0, right if 1)
-store new LED bitmask in memory
Button interrupt handler:
-read direction flag/bit
-XOR 0x1 to toggle
-store updated direction flag/bit
And remember if you're using registers to store those values to push them onto the stack before running your interrupt handler.
"nah surge you should totally check out From the Depths, it so much smoother and better than those other sandbox builders"
"I dunno"
"totally man"
"ehhh lemme look it up on youtube"
So at first I was reading Explain xkcd, and next thing I knew I had just stopped browsing Wikipedia and installed a Usenet client on my computer and was googling for a server that carried the newsgroups I was looking for.
And place some stone and ore within the dirt, to make it seem a bit more natural.
Those finishing touches come soon
But not quiiiite yet. Which is why, aside from placing enough in some of the homes to get NPCs in there, they're entirely unfurnished. I'm mostly walking into it a bit at a time, and I'm close to being finished with the framework. Then comes the small things that make it look extra nice, such as slopes, halfblocks, and more than just dirt
;Delay subroutines
Delay500ms
MOVLW 0x03 ;499994 cycles on 4Mhz
MOVWF Count1
MOVLW 0x18
MOVWF Count2
MOVLW 0x02
MOVWF Count3
Delay_0
DECFSZ Count1, F
goto $+2
DECFSZ Count2, F
goto $+2
DECFSZ Count3, F
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
return
END
I'm not sure will it work as intended in the SK40C board and I'm kinda late now the lab is closed,
so far I think it'll go one way as intended but I'm unsure will it go the other wat when a switch is pressed.
and for the last time is anyone going to fix the code box!