Jump to content
IGNORED

IDE card usage


Recommended Posts

I thought I'd start a new topic related to the use of the IDE card in order to keep things in one place for easy reference.

How does one access the clock on the card from assembly? I'd like to do so from within the pcode system.

  • Like 1
Link to comment
Share on other sites

It looks like you'd start with the file: ide-p00l2-bq4847.inc

 

Fred's code may help glue together all the technical overload that is at: http://unige.ch/medecine/nouspikel/ti99/ide2.htm#Time and date, where you have to jump all over the place and the answer ends up being, depends... which clock chip is being used? ... 

  • Like 1
Link to comment
Share on other sites

I don't have access to the IDE files from the psystem. I'm not even sure it sees the card at all as a block device, and still not knowing where the PCB's are in VDP and what their structure is there is little I can do to remedy that situation. I was hoping for a way to access the clock chip registers directly but it looks more complicated than I first imagined. I'll have to dig deeper.

  • Like 1
Link to comment
Share on other sites

I haven't tried any of this but my read of the hardware page seems like the following process for any one clock chip: 

 

1. Set Cru bits to enable card and clock into the memory map. 

2. Depending on the clock chip, set a page register so the actual clock registers are mapped in.

3. Set a latch register so the time in the read registers are stable ( only necessary if reading multiple registers like hours, minutes and seconds, if you just want 1, then not necessary)

4. write to a register select address to specify the register you want to read

5. Read from the register read address.

( This is a bit like accessing VDP registers)

6. Repeat 4 and 5 as needed.

7. Unlatch, if you latched.

8. Clear the crubits that enabled the card.

 

The details of which page to enable depends on the clock chip, and which registers to read as well.

 

Maybe someone with experience can correct me?

 

For simplicity, I'd focus on just the clock chip you have. 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Yep, it's all there, but spread out on the rather large IDE design page. Each clock chip has a different section on enabling it, and another on the SRAM paging, and then the actual register usage.... 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

The new IDE card uses the BQ4847 clock chip, and the 838 RTC module uses a pin compatible chip as well.

Is the chip's RAM space automatically mapped when the IDE card is turned on or is there another CRU bit I need to set? I can't seem to find any mention of the latter in Nouspikel's docs or in Fred's DSR...

As things stand with just the IDE card activated, I am getting static values from my clock reads which tells me that the RTC registers addresses are not mapped.

 

 

Link to comment
Share on other sites

Here's what I have so far trying first to get the RTC time. All I get is unchanging static values. I must be missing something...

;ide card rtc low-level access routines

        .proc   ctime,3
;get time
;usage: ctime(intvarsec, intvarmin, intvarhr)

        .def    pcodeon,pcodoff,procret,pmeret
        mov     r11,procret
        bl      @pcodoff
        li      r12,1900h
        sbo     0
        mov     *r10+,r1        ;get pointer to hours variable
        mov     *r10+,r2        ;get pointer to minutes variable
        mov     *r10,r3         ;get pointer to seconds variable
        li      r4,0800h        ;latch rtc registers
        socb    r4,@403ch
        clr     r4
        movb    @4020,r4        ;get seconds
        swpb    r4
        mov     r4,*r3          
        clr     r4
        movb    @4024,r4        ;get minutes
        swpb    r4
        mov     r4,*r2
        clr     r4
        movb    @4028,r4        ;get hours
        swpb    r4
        mov     r4,*r1
        li      r4,0800h        ;unlatch rtc registers
        szcb    r4,@403ch
        sbz     0               ;inactivate ide card
        bl      @pcodeon
        mov     @procret,r11
        b       *r11
         
procret .word
pmeret  .word

pcodeon li      r12,1f00h       ;activate pcode card
        sbo     0
        mov     @pmeret,r12     ;retrieve pme pointer
        b       *r11
        
pcodoff mov     r12,@pmeret     ;save pme pointer
        li      r12,1f00h       ;inactivate pcode card
        sbz     0
        b       *r11
        
        .end

 

Link to comment
Share on other sites

OK after some digging into Fred's DSR source it turns out that I need to do an SBO 1 to map the >4000->40FF RAM space where the RTC registers live. I also had a few typos in the listing as well. In any case it works now, but the time values are wrong because I believe the RTC registers use BCD and not HEX. Now I need to figure out how to convert from BCD to HEX in assembly.

;ide card rtc low-level access routines

        .proc   ctime,3
;get time
;usage: ctime(intvarsec, intvarmin, intvarhr)

        .def    pcodeon,pcodoff,procret,pmeret
        mov     r11,@procret
        bl      @pcodoff
        li      r12,1900h       ;activate ide card at cru >1900
        sbo     0
        sbo     1               ;enable mapping of >4000 - >40ff space
        sbo     3               ;fixed page at >4000 - >40ff
        mov     *r10+,r1        ;get pointer to hours variable
        mov     *r10+,r2        ;get pointer to minutes variable
        mov     *r10,r3         ;get pointer to seconds variable
        li      r4,0800h        ;latch rtc registers
        socb    r4,@403ch
        clr     r4
        movb    @4020h,r4        ;get seconds
        swpb    r4
        mov     r4,*r3          
        clr     r4
        movb    @4024h,r4        ;get minutes
        swpb    r4
        mov     r4,*r2
        clr     r4
        movb    @4028h,r4        ;get hours
        swpb    r4
        mov     r4,*r1
        li      r4,0800h        ;unlatch rtc registers
        szcb    r4,@403ch
        sbz     1               ;inactivate ram mapping
        sbz     0               ;inactivate ide card
        bl      @pcodeon
        mov     @procret,r11
        b       *r11
         
procret .word
pmeret  .word

pcodeon li      r12,1f00h       ;activate pcode card
        sbo     0
        mov     @pmeret,r12     ;retrieve pme pointer
        b       *r11
        
pcodoff mov     r12,@pmeret     ;save pme pointer
        li      r12,1f00h       ;inactivate pcode card
        sbz     0
        b       *r11
        
        .end

 

  • Like 3
Link to comment
Share on other sites

Here's the routine with the bcd conversion part done. I'll add the date fetching later today.

;ide card rtc low-level access routines

        .proc   ctime,3
;get time
;usage: ctime(intvarsec, intvarmin, intvarhr)

        .def    pcodeon,pcodoff,procret,pmeret,bcd2hex
        mov     r11,@procret
        bl      @pcodoff
        li      r12,1900h       ;activate ide card at cru >1900
        sbo     0
        sbo     1               ;enable mapping of >4000 - >40ff space
        sbo     3               ;fixed page at >4000 - >40ff
        mov     *r10+,r1        ;get pointer to hours variable
        mov     *r10+,r2        ;get pointer to minutes variable
        mov     *r10,r3         ;get pointer to seconds variable
        li      r4,0800h        ;latch rtc registers
        socb    r4,@403ch
        clr     r4
        movb    @4020h,r4       ;get seconds
        swpb    r4
        bl      @bcd2hex        ;convert to hex
        mov     r6,*r3
        clr     r4
        movb    @4024h,r4       ;get minutes
        swpb    r4
        bl      @bcd2hex        ;convert to hex
        mov     r6,*r2
        clr     r4
        movb    @4028h,r4       ;get hours
        swpb    r4
        bl      @bcd2hex
        mov     r6,*r1
        li      r4,0800h        ;unlatch rtc registers
        szcb    r4,@403ch
        sbz     1               ;inactivate ram mapping
        sbz     0               ;inactivate ide card
        bl      @pcodeon
        mov     @procret,r11
        b       *r11
         
procret .word
pmeret  .word

pcodeon li      r12,1f00h       ;activate pcode card
        sbo     0
        mov     @pmeret,r12     ;retrieve pme pointer
        b       *r11
        
pcodoff mov     r12,@pmeret     ;save pme pointer
        li      r12,1f00h       ;inactivate pcode card
        sbz     0
        b       *r11
        
bcd2hex mov     r4,r5           ;isolate low digit
        andi    r5,000fh
        mov     r4,r6           ;isolate high digit
        andi    r6,00f0h
        srl     r6,4
        mov     r6,r4           ;save original value
        sla     r6,3            ;multiply by 8
        sla     r4,1            ;multiply original value by 2
        a       r4,r6           ;high value has now been multiplied by 10
        a       r5,r6           ;add low and high numbers. r6 now has hex value
        b       *r11
        
        .end

 

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...