11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PICBASIC</strong> <strong>PLUS</strong> CompilerMaking SHOUT work with a particular device is a matter of matchingthe mode and number of bits to that device’s protocol. Most manufacturersuse a timing diagram to illustrate the relationship of clock anddata. One of the most important items to look for is which bit of thedata should be transmitted first; most significant bit (MSB) or leastsignificant bit (LSB).Example : SHOUT DTA , CLK , MSBFIRST , [ 250 ]In the above example, the SHOUT command will write to I/O pin DTA(the Dpin) and will generate a clock signal on I/O CLK (the Cpin). TheSHOUT command will generate eight clock pulses while writing eachbit (of the 8-bit value 250) onto the data pin (Dpin). In this case, it willstart with the most significant bit first as indicated by the Mode valueof MSBFIRST.By default, SHOUT transmits eight bits, but you can set it to shift anynumber of bits from 1 to 16 with the Bits argument. For example: -SHOUT DTA , CLK , MSBFIRST , [ 250 \ 4 ]Will only output the lowest 4 bits (%0000 in this case). Some devicesrequire more than 16 bits. To solve this, you can use a single SHOUTcommand with multiple values. Each value can be assigned a particularnumber of bits with the Bits argument. As in: -SHOUT DTA , CLK , MSBFIRST , [ 250 \ 4 , 1045 \ 16]The above line of code will first shift out four bits of the number 250(%1111) and then 16 bits of the number 1045(%0000010000010101). The two values together make up a 20 bitvalue.See also :SHIN123Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!